I have a project configured by CMake
. It has a program and a some shared libraries.
target_link_libraries
statement).LoadLibrary
Win32 API.We use Visual Studio 2015 as CMake
target compiler. But from this IDE, when I start my program (press F5) after I modified some code, only the program and linked shared libraries are compiled. The "plugins" to be loaded at runtime are not compiled and so the code do not match the binary.
Is there a way to add a "build dependency", saying that some libraries should be compiled if out-of-date before a program is executed, even if this last one does not link them?
Specify libraries or flags to use when linking a given target and/or its dependents. Usage requirements from linked library targets will be propagated. Usage requirements of a target's dependencies affect compilation of its own sources.
There is a CMake command exactly for this purpose: add_dependencies. It should do what you are looking for. Example:
add_executable(mainTarget SomeSource.cpp)
add_library(linkedLib SomeOtherSource.cpp)
add_library(libToBeLoaded MODULE MoreSource.cpp)
target_link_libraries(mainTarget PRIVATE linkedLib)
# This is it:
add_dependencies(mainTarget libToBeLoaded)
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With