<div dir="ltr">Hi<br><br>I am porting a gnu make project to CMake. Initially I am using the Ninja <br>generator and running in Ubuntu 18.04.<br><br>The project consists of a static library 'libKernel.a', which includes main.cpp, <br>which we link into an executable: 'MyApp'. The program dynamically loads shared<br>libraries that need objects from 'libKernel.a' so we use options such as <br>-whole-archive and -export-dynamic.<br><br>The original link command for the program is:<br><br>g++ -o _gnuRelease/MyApp -Wl,-whole-archive,-export-dynamic,--no-as-needed ../Kernel/_gnuRelease/libKernel.a -Wl,--as-needed,--no-whole-archive -lpthread -ldl<br><br>In CMake I have implemented this as:<br><br>add_executable(MyApp ../Kernel/main.cpp)<br>set_target_properties(MyApp PROPERTIES ENABLE_EXPORTS TRUE)<br>target_link_libraries(MyApp Kernel ${CMAKE_DL_LIBS})<br><br>and CMake's link command is:<br><br>/usr/bin/c++  -O3 -DNDEBUG  -Wl,--export-dynamic -rdynamic CMakeFiles/MyApp.dir/Kernel/main.cpp.o  -o release/MyApp  Kernel/libKernel.a -ldl<br><br>The CMake build is failing to link at runtime as some symbols are missing.<br><br>I have two issues here:<br><br>1) In the CMake implementation I removed main.cpp from libKernel and specified <br>it as the executable source file, as it seems that the executable needs at <br>least one SOURCE file.  Is there a way around this?<br><br>2) How can I tell CMake to use the '-Wl,-whole-archive,-export-dynamic,--no-as-needed' flags?<br><br>Best regards<br><br>David<br></div>