Reputation: 935
I am using CMake in to custom create files on the fly from files that exist in a specified location. This is my code:
file(GLOB files "${path}/*.data")
file(GLOB sidedata "${path}/*.sidedata")
foreach(file ${files})
get_filename_component(name ${file} NAME_WE)
add_custom_command(
OUTPUT "${name}.library"
DEPENDS ${path} ${file} ${sidedata} ${CMAKE_CURRENT_SOURCE_DIR}/makelibrary.pl
COMMAND ${CMAKE_CURRENT_SOURCE_DIR}/makelibrary.pl ARGS ${sidedata} ${file}
COMMENT "Generating ${name}.library"
)
add_custom_target(${name}.target ALL DEPENDS ${name}.library)
install(FILES ${CMAKE_CURRENT_BINARY_DIR}/${name}.library DESTINATION ${somewhere})
endforeach()
The issue I am seeing that the files
and sidedata
are cached - if a new file is added to path
location it will not be detected; if a file is removed, the dependency check fails.
How do I resolve this problem?
Upvotes: 5
Views: 3864
Reputation: 28989
I am using the module CheckCXXSourceRuns
like this
include(CheckCXXSourceRuns)
check_cxx_source_runs("
#include ...
int main() {
...
}" HAVE_AVX_EXTENSIONS)
To force CMake to reevaluate this on every call to cmake ..
, I am calling cmake .. -U HAVE_\*
. This will undefine the HAVE_
variables, so that CMake has to reevaluate them.
Source: https://blogs.kde.org/2011/02/05/how-selectively-remove-entries-cmake-cache-command-line
Upvotes: 0
Reputation: 935
Just to close this question, I followed the Fraser's suggestion : rerun plain cmake <source area>
to update the file list.
Also, the variables were not in the cache.
Upvotes: 2