<div dir="ltr">Hello everybody,<div><br></div><div>I moving a makefile to cmake, and after errors I could check that order in link chain was important.</div><div><br></div><div>1) CMake generates this link.txt (error when linking)</div>
<div>/usr/bin/c++ -lfusion_io -ladios -lmxml -lmpi -lopen-rte -lopen-pal -lpthread -lstdc++ CMakeFiles/niio-main.dir/main.cpp.o -o niio-main -rdynamic -L/home/testuser/dev/niio/lib -L/home/testuser/dev/niio/openmpi/lib</div>
<div><br></div><div><br></div><div>2) Desired linking that works:</div><div><div>/usr/bin/c++ CMakeFiles/niio-main.dir/main.cpp.o -lfusion_io -ladios -lmxml -lmpi -lopen-rte -lopen-pal -lpthread -lstdc++ -o niio-main -rdynamic -L/home/testuser/dev/niio/lib -L/home/testuser/dev/niio/openmpi/lib</div>
</div><div><br></div><div><br></div><div>My question is, how to fix in my CMakeLists.txt to have main.cpp.o first in the sequence of the link command?</div><div><br></div><div><br></div><div>My current code is:</div><div>
<br></div><div><div>set(TARGET_NAME "niio-main")</div></div><div><br></div><div><div>link_directories("${PROJECT_SOURCE_DIR}/lib")</div><div>link_directories("${PROJECT_SOURCE_DIR}/openmpi/lib")<br>
</div></div><div><br></div><div><div>add_executable(${TARGET_NAME} main.cpp)</div><div><br></div><div>include_directories("${PROJECT_SOURCE_DIR}")<br></div><div>include_directories("${PROJECT_SOURCE_DIR}/openmpi/include")<br>
</div></div><div><br></div><div>add_definitions( -DOMPI_SKIP_MPICXX -DDEBUG -DNI_IO -DNI_MPI )<br></div><div><br></div><div><div>set_target_properties(${TARGET_NAME} PROPERTIES COMPILE_FLAGS "-fPIC -g -Wall -Wno-deprecated")</div>
<div><br></div><div>set_target_properties(${TARGET_NAME} PROPERTIES LINK_FLAGS "-lfusion_io -ladios -lmxml -lmpi -lopen-rte -lopen-pal -lpthread -lstdc++")<br></div><div><br></div></div><div><br></div><div><br>
</div>
<div>Thank you very much,</div><div><br></div><div>JP</div></div>