Skip to content

Commit

Permalink
made it possible to override FILESDIR in CMake
Browse files Browse the repository at this point in the history
  • Loading branch information
firewave committed May 24, 2024
1 parent c5791f6 commit 76ade5b
Show file tree
Hide file tree
Showing 4 changed files with 17 additions and 3 deletions.
2 changes: 1 addition & 1 deletion cmake/compilerDefinitions.cmake
Original file line number Diff line number Diff line change
Expand Up @@ -61,5 +61,5 @@ if(NO_WINDOWS_SEH)
add_definitions(-DNO_WINDOWS_SEH)
endif()

file(TO_CMAKE_PATH ${FILESDIR} _filesdir)
file(TO_CMAKE_PATH "${FILESDIR_DEF}" _filesdir)
add_definitions(-DFILESDIR="${_filesdir}")
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
2 changes: 2 additions & 0 deletions test/cli/other_test.py
Original file line number Diff line number Diff line change
Expand Up @@ -1535,6 +1535,7 @@ def test_cpp_probe_2(tmpdir):
assert_cppcheck(args, ec_exp=0, err_exp=[], out_exp=[])


# TODO: test with FILESDIR
def test_lib_lookup(tmpdir):
test_file = os.path.join(tmpdir, 'test.c')
with open(test_file, 'wt'):
Expand All @@ -1557,6 +1558,7 @@ def test_lib_lookup(tmpdir):
]


# TODO: test with FILESDIR
def test_lib_lookup_notfound(tmpdir):
test_file = os.path.join(tmpdir, 'test.c')
with open(test_file, 'wt'):
Expand Down

0 comments on commit 76ade5b

Please sign in to comment.