Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

CMake doesn't recompile source file when it's changed?

Tags:

c++

linux

cmake

I'm using cmake to build my library, when i change one of LIB_SRCS files and type make in command line it doesn't rcompile that file!

set (LIB_SRCS
  ${PROJECT_SOURCE_DIR}/src/A.cpp
  ${PROJECT_SOURCE_DIR}/src/B.cpp
  ${PROJECT_SOURCE_DIR}/src/C.cpp
)
add_library (mylib SHARED ${LIB_SRCS})
add_dependencies(mylib ${LIB_SRCS})
like image 716
Mustafa Avatar asked Dec 17 '14 17:12

Mustafa


1 Answers

the first thing you should check is modification time of .o and .so vs .cpp When mtime of .cpp is greater than .o then it should rebuild. You can test it even without modification by 'touch' file.cpp.

In some strange scenario time can be mismatched due to many reasons and then it will not work. Possible reason can be for example some demon which plays with system time, or using network file system, and others.

However in real life scenario it is usually not make mistake but developer mistake :-)

like image 86
wiesniak Avatar answered Sep 30 '22 08:09

wiesniak