Dear CMake users,
I have this BIG project which has tons of subdirectories (many levels).
In each (final) subdirectory, I create targets (executables and libraires).
So I have my top level CMakeLists.txt and one CMakeLists.txt file (which is
also a project) in each subdirectory.
Everything compiles just fine!
My question is a general CMake question and is the following:
Imagine I can use ITK in my project. To do that, in the top level
CMakeLists.txt I define a variable USE_ITK.
If ITK is used, I search for it and I include useful files:
OPTION(USE_ITK "If ON, search for Insight Toolkit package" OFF)
IF(USE_ITK)
FIND_PACKAGE(ITK)
IF(ITK_FOUND)
INCLUDE(${ITK_USE_FILE})
ELSE(ITK_FOUND)
MESSAGE(FATAL_ERROR "ITK not found. Please set ITK_DIR.")
ENDIF(ITK_FOUND)
ELSE(USE_ITK)
SET(ITK_FOUND OFF)
ENDIF(USE_ITK)
Now, if one subdirectory's project uses ITK, I have the following code (in the
subdir's CMakeLists.txt):
FIND_PACKAGE( ITK )
IF( NOT ITK_FOUND )
MESSAGE( "Project ${PROJECT_NAME} requires ITK and ITK was not found.
${PROJECT_NAME} will not be built." )
RETURN()
ENDIF()
INCLUDE( ${ITK_USE_FILE} )
As you can see, find_package(ITK) and INCLUDE( ${ITK_USE_FILE} ) are at least
called twice (in fact much more).
Is there any performance issue the method describe above?
Since it's not my code and since i'm a CMake newbee, I'd like to understand if
this is normal.
I would say that this should be done once in the top level CMakeLists.txt.
In the subdirs' CMakeLists, we should use only ITK_FOUND to decide if we build
the target or not.
Some people of my team agree and some don't.
What is the best way to proceed?
Many thanks!
Vincent
_______________________________________________
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