Re: [CMake] CMake rebuilding too much
On 12-10-2010 13:24, Michael Wild wrote: The FORCE is OK, but you should do this only once, and only if CMAKE_CXX_FLAGS is the default. You don't want to upset your users, do you? Something like this should do: if(CMAKE_COMPILER_IS_GNUCXX AND NOT __CHECKED_CXX_FLAGS) # this is the guard so we do this only once set(__CHECKED_CXX_FLAGS TRUE CACHE INTERNAL "Whether we checked the CXX flags already") if("${CMAKE_CXX_FLAGS}" STREQUAL "${CMAKE_CXX_FLAGS_INIT}") # only override defaults if the user didn't do so already! set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} Wall -Woverloaded-virtual -Wno-unknown-pragmas -Werror" CACHE STRING "Flags used by the compiler during all build types." FORCE) endif() endif() This way the flags end up in the cache and can be changed by the user without having to change the CMakeLists.txt file, and it also respects the user's choice of flags if he provides them in the initial CMake-run. Thanks, I'll try it that way. Thomas ___ Powered by www.kitware.com Visit other Kitware open-source projects at http://www.kitware.com/opensource/opensource.html Please keep messages on-topic and check the CMake FAQ at: http://www.cmake.org/Wiki/CMake_FAQ Follow this link to subscribe/unsubscribe: http://www.cmake.org/mailman/listinfo/cmake
Re: [CMake] CMake rebuilding too much
On 12. Oct, 2010, at 13:07 , Thomas Sondergaard wrote: > On 07-10-2010 14:46, Bill Hoffman wrote: > >> You are going to have to give more information or a small example that >> shows the problem. It should not be doing that. You could try running >> make -d to figure out why make is thinking it needs to do that. >> >> -Bill >> > > I found the problem. I had the following in my top-level CMakeLists.txt: > > if(CMAKE_COMPILER_IS_GNUCXX) > SET(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -Wall -Woverloaded-virtual > -Wno-unknown-pragmas -Werror" CACHE STRING "Flags used by the compiler during > all build types." FORCE) > endif() > > I don't know why I had the FORCE in there, but it caused the warning flags > above to be appended again whenever a CMakeLists.txt file was touched. > Removing FORCE fixed it. > > Thanks, > > Thomas The FORCE is OK, but you should do this only once, and only if CMAKE_CXX_FLAGS is the default. You don't want to upset your users, do you? Something like this should do: if(CMAKE_COMPILER_IS_GNUCXX AND NOT __CHECKED_CXX_FLAGS) # this is the guard so we do this only once set(__CHECKED_CXX_FLAGS TRUE CACHE INTERNAL "Whether we checked the CXX flags already") if("${CMAKE_CXX_FLAGS}" STREQUAL "${CMAKE_CXX_FLAGS_INIT}") # only override defaults if the user didn't do so already! set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} Wall -Woverloaded-virtual -Wno-unknown-pragmas -Werror" CACHE STRING "Flags used by the compiler during all build types." FORCE) endif() endif() This way the flags end up in the cache and can be changed by the user without having to change the CMakeLists.txt file, and it also respects the user's choice of flags if he provides them in the initial CMake-run. -- There is always a well-known solution to every human problem -- neat, plausible, and wrong. H. L. Mencken PGP.sig Description: This is a digitally signed message part ___ Powered by www.kitware.com Visit other Kitware open-source projects at http://www.kitware.com/opensource/opensource.html Please keep messages on-topic and check the CMake FAQ at: http://www.cmake.org/Wiki/CMake_FAQ Follow this link to subscribe/unsubscribe: http://www.cmake.org/mailman/listinfo/cmake
Re: [CMake] CMake rebuilding too much
On 07-10-2010 14:46, Bill Hoffman wrote: You are going to have to give more information or a small example that shows the problem. It should not be doing that. You could try running make -d to figure out why make is thinking it needs to do that. -Bill I found the problem. I had the following in my top-level CMakeLists.txt: if(CMAKE_COMPILER_IS_GNUCXX) SET(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -Wall -Woverloaded-virtual -Wno-unknown-pragmas -Werror" CACHE STRING "Flags used by the compiler during all build types." FORCE) endif() I don't know why I had the FORCE in there, but it caused the warning flags above to be appended again whenever a CMakeLists.txt file was touched. Removing FORCE fixed it. Thanks, Thomas ___ Powered by www.kitware.com Visit other Kitware open-source projects at http://www.kitware.com/opensource/opensource.html Please keep messages on-topic and check the CMake FAQ at: http://www.cmake.org/Wiki/CMake_FAQ Follow this link to subscribe/unsubscribe: http://www.cmake.org/mailman/listinfo/cmake
Re: [CMake] CMake rebuilding too much
On 10/7/2010 8:21 AM, Thomas Sondergaard wrote: I've got a reasonably big project with 30+ shared libraries and 70+ executables all in one cmake-based project. Today I changed one line in a CMakeLists.txt in a sub-directory to link boost program_options in one particular executable, and it caused cmake to decide that it needed to recompile everything. Why does it do that? Is there a way that I can have cmake tell me the reason? This is the rather innocuous change that caused CMake to rebuild a lot more than 'srscrubber'. < target_link_libraries(srscrubber camutility) > target_link_libraries(srscrubber camutility ${Boost_PROGRAM_OPTIONS_LIBRARY}) I'm using cmake version 2.6-patch 4 on centos linux 5.5 with the default makefile generator. You are going to have to give more information or a small example that shows the problem. It should not be doing that. You could try running make -d to figure out why make is thinking it needs to do that. -Bill ___ Powered by www.kitware.com Visit other Kitware open-source projects at http://www.kitware.com/opensource/opensource.html Please keep messages on-topic and check the CMake FAQ at: http://www.cmake.org/Wiki/CMake_FAQ Follow this link to subscribe/unsubscribe: http://www.cmake.org/mailman/listinfo/cmake
[CMake] CMake rebuilding too much
I've got a reasonably big project with 30+ shared libraries and 70+ executables all in one cmake-based project. Today I changed one line in a CMakeLists.txt in a sub-directory to link boost program_options in one particular executable, and it caused cmake to decide that it needed to recompile everything. Why does it do that? Is there a way that I can have cmake tell me the reason? This is the rather innocuous change that caused CMake to rebuild a lot more than 'srscrubber'. < target_link_libraries(srscrubber camutility) > target_link_libraries(srscrubber camutility ${Boost_PROGRAM_OPTIONS_LIBRARY}) I'm using cmake version 2.6-patch 4 on centos linux 5.5 with the default makefile generator. Thanks, Thomas ___ Powered by www.kitware.com Visit other Kitware open-source projects at http://www.kitware.com/opensource/opensource.html Please keep messages on-topic and check the CMake FAQ at: http://www.cmake.org/Wiki/CMake_FAQ Follow this link to subscribe/unsubscribe: http://www.cmake.org/mailman/listinfo/cmake