Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[cmake] Generate CMakeArgs.txt file to store CMake src, build dir and invocation arguments #815

Merged
merged 1 commit into from
Mar 10, 2024
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
14 changes: 14 additions & 0 deletions CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,20 @@ set(CMAKE_CXX_EXTENSIONS NO)

include(GNUInstallDirs)

# MUST be done before call to clad project
get_cmake_property(_cache_vars CACHE_VARIABLES)
foreach(_cache_var ${_cache_vars})
get_property(_helpstring CACHE ${_cache_var} PROPERTY HELPSTRING)
if(_helpstring STREQUAL
"No help, variable specified on the command line.")
set(CMAKE_ARGS "${CMAKE_ARGS} -D${_cache_var}=\"${${_cache_var}}\"")
endif()
endforeach()

# Generate CMakeArgs.txt file with source, build dir and command line args
write_file("${CMAKE_CURRENT_BINARY_DIR}/CMakeArgs.txt"
"-S${CMAKE_SOURCE_DIR} -B${CMAKE_CURRENT_BINARY_DIR} ${CMAKE_ARGS}")

if(POLICY CMP0075)
cmake_policy(SET CMP0075 NEW)
endif()
Expand Down
Loading