[CMake] Main program not getting rebuilt when library changes.
Bill Hoffman
bill.hoffman at kitware.com
Mon Oct 6 10:51:45 EDT 2014
Bill,
I want to reset this conversation a bit. What you are doing should work
no problem. Most of the suggestions should not be needed. I do agree
that glob is bad, but it will cause different problems. Anyway, I
created the following example based on your posts and it works with VS
2010. Can you try this and report back? This could be a bug in VS as
CMake has very little to do with depends like this and the VS IDE.
I did this to test:
$ ls -l b/cmTestMain/Debug/
total 684
-rwxr-xr-x 1 hoffman Domain Users 28160 Oct 6 10:47 cmTestMain.exe
hoffman at quasar ~/Work/dep
$ touch cmTestLib/MySub.cpp
#build from VS IDE and exe relinks
hoffman at quasar ~/Work/dep
$ ls -l b/cmTestMain/Debug/
total 684
-rwxr-xr-x 1 hoffman Domain Users 28160 Oct 6 10:48 cmTestMain.exe
hoffman at quasar ~/Work/dep
$ touch cmTestLib/MySub.h
# build from VS IDE exe relinks again
hoffman at quasar ~/Work/dep
$ ls -l b/cmTestMain/Debug
total 684
-rwxr-xr-x 1 hoffman Domain Users 28160 Oct 6 10:49 cmTestMain.exe
top level:
-----------
cmake_minimum_required (VERSION 2.8)
project(cmTest)
add_subdirectory (cmTestLib)
add_subdirectory (cmTestMain)
cmTestLib
--------------
add_library (cmTestLib STATIC MySub.cpp MySub.h)
------ cmTestLib/MySub.cpp
#include "MySub.h"
int hello() { return 0;}
----- cmTestLib/MySub.h
int hello();
cmTestMain
----------------
include_directories (${cmTest_SOURCE_DIR}/cmTestLib)
add_executable (cmTestMain cmTestMain.cpp)
target_link_libraries (cmTestMain cmTestLib)
Here are the source files:
------ cmTestLib/MySub.cpp
#include "MySub.h"
int hello() { return 0;}
----- cmTestLib/MySub.h
int hello();
cmTestMain/cmTestMain.cpp
#include "MySub.h"
int main()
{
return hello();
}
More information about the CMake
mailing list