I have written a CMakeLists.txt file including 2 executables (target1 and target2):
ADD_EXECUTABLE(target1 ${CXX_FILES})
TARGET_LINK_LIBRARIES(target1 ${requiredlibs})
ADD_EXECUTABLE(target2 ${CXX_FILES} ${OTHER_CXX_FILES})
TARGET_LINK_LIBRARIES(target2 ${requiredlibs})
Now every time when I run make without any parameters both targets are rebuilt. But I want to define target1 as default executable so that running make without any parameters only builds target1. For building target2 I would run make target2.
Is this possible?
In the Makefile created by CMake there is the following definition:
default_target: all
I think I need a way to set this default_target to target1.
Another problem I have is that make always rebuilds the targets, even if no source file has been changed.
An example CMakeLists.txt that does what you requested:
For me it does not rebuild the target if the source files are not changed (or modification time did not change). Output I get:
Note that the second make does not rebuild anything.
(you could read the CMake manual for this type of information)