Skip to content

Commit

Permalink
fixed #12766 - made it possible to override FILESDIR in CMake (#6437)
Browse files Browse the repository at this point in the history
  • Loading branch information
firewave authored May 26, 2024
1 parent 234eec5 commit 5b025c8
Show file tree
Hide file tree
Showing 3 changed files with 18 additions and 4 deletions.
6 changes: 4 additions & 2 deletions cmake/compilerDefinitions.cmake
Original file line number Diff line number Diff line change
Expand Up @@ -61,5 +61,7 @@ if(NO_WINDOWS_SEH)
add_definitions(-DNO_WINDOWS_SEH)
endif()

file(TO_CMAKE_PATH ${FILESDIR} _filesdir)
add_definitions(-DFILESDIR="${_filesdir}")
if(FILESDIR_DEF)
file(TO_CMAKE_PATH "${FILESDIR_DEF}" _filesdir)
add_definitions(-DFILESDIR="${_filesdir}")
endif()
13 changes: 11 additions & 2 deletions cmake/options.cmake
Original file line number Diff line number Diff line change
Expand Up @@ -75,6 +75,9 @@ option(NO_UNIX_SIGNAL_HANDLING "Disable usage of Unix Signal Handling"
option(NO_UNIX_BACKTRACE_SUPPORT "Disable usage of Unix Backtrace support" OFF)
option(NO_WINDOWS_SEH "Disable usage of Windows SEH" OFF)

# TODO: disable by default like make build?
option(FILESDIR "Hard-coded directory for files to load from" OFF)

if(CMAKE_VERSION VERSION_EQUAL "3.16" OR CMAKE_VERSION VERSION_GREATER "3.16")
set(CMAKE_DISABLE_PRECOMPILE_HEADERS Off CACHE BOOL "Disable precompiled headers")
# need to disable the prologue or it will be treated like a system header and not emit any warnings
Expand All @@ -95,5 +98,11 @@ set(CMAKE_RUNTIME_OUTPUT_DIRECTORY ${PROJECT_BINARY_DIR}/bin)
set(CMAKE_ARCHIVE_OUTPUT_DIRECTORY ${PROJECT_BINARY_DIR}/lib)
set(CMAKE_LIBRARY_OUTPUT_DIRECTORY ${PROJECT_BINARY_DIR}/lib)

set(FILESDIR ${CMAKE_INSTALL_PREFIX}/share/${PROJECT_NAME} CACHE STRING "Cppcheck files directory")

string(LENGTH "${FILESDIR}" _filesdir_len)
# override FILESDIR if it is set or empty
if(FILESDIR OR ${_filesdir_len} EQUAL 0)
# TODO: verify that it is an abolute path?
set(FILESDIR_DEF ${FILESDIR})
else()
set(FILESDIR_DEF ${CMAKE_INSTALL_PREFIX}/share/${PROJECT_NAME} CACHE STRING "Cppcheck files directory")
endif()
3 changes: 3 additions & 0 deletions cmake/printInfo.cmake
Original file line number Diff line number Diff line change
Expand Up @@ -95,6 +95,9 @@ if(USE_BOOST)
endif()
message(STATUS "USE_LIBCXX = ${USE_LIBCXX}")
message(STATUS)
message(STATUS "FILESDIR = ${FILESDIR}")
message(STATUS "FILESDIR_DEF = ${FILESDIR_DEF}")
message(STATUS)

if(${ANALYZE_ADDRESS})
message("##########################################################")
Expand Down

0 comments on commit 5b025c8

Please sign in to comment.