Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How to tell CMake not to cache variables

Tags:

cmake

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?

like image 225
David R. Avatar asked Oct 31 '22 04:10

David R.


1 Answers

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.

like image 124
David R. Avatar answered Jan 04 '23 14:01

David R.