Use CMAKE_CURRENT_LIST_DIR for local includes to simplify usage

This means that we no longer need to modify the module path for CMake
before including the root script.
This commit is contained in:
Danny Robson 2022-06-15 10:46:52 +10:00
parent b09ea14d5a
commit 54f0855312
8 changed files with 19 additions and 33 deletions

View File

@ -12,7 +12,7 @@ macro(check_link_flag _variable _flag)
__check_link_flag_${_name} __check_link_flag_${_name}
"${CMAKE_CURRENT_BINARY_DIR}/CMakeTmp" "${CMAKE_CURRENT_BINARY_DIR}/CMakeTmp"
SOURCES SOURCES
"${NC_CMAKE_BASE}/test_link_flag.cpp") "${CMAKE_CURRENT_LIST_DIR}/test_link_flag.cpp")
if (__check_link_flag_${_name}) if (__check_link_flag_${_name})
message (STATUS "checking linker flag ${_flag} - found") message (STATUS "checking linker flag ${_flag} - found")

View File

@ -13,22 +13,8 @@ set (THREADS_PREFER_PTHREAD_FLAG ON)
find_package (Threads REQUIRED) find_package (Threads REQUIRED)
link_libraries (Threads::Threads) link_libraries (Threads::Threads)
# Set the variable NC_CMAKE_BASE to the root path of this collection of cmake include ("${CMAKE_CURRENT_LIST_DIR}/nc_cxx.cmake")
# files so that we can reliably point to soure files contained therein include ("${CMAKE_CURRENT_LIST_DIR}/nc_sanitizer.cmake")
# (eg, the search_lib.cpp tests and friends). include ("${CMAKE_CURRENT_LIST_DIR}/nc_platform.cmake")
foreach (d ${CMAKE_MODULE_PATH}) include ("${CMAKE_CURRENT_LIST_DIR}/nc_optimisation.cmake")
if (EXISTS "${d}/nc.cmake") include ("${CMAKE_CURRENT_LIST_DIR}/nc_warnings.cmake")
set (NC_CMAKE_BASE "${d}")
break()
endif ()
endforeach()
if (NOT NC_CMAKE_BASE)
message (FATAL_ERROR "Unable to locate the NC CMake directory")
endif ()
include (nc_cxx)
include (nc_sanitizer)
include (nc_platform)
include (nc_optimisation)
include (nc_warnings)

View File

@ -15,9 +15,9 @@ set (CMAKE_C_FLAGS_DEBUG "")
############################################################################### ###############################################################################
include (compile_flag) include ("${CMAKE_CURRENT_LIST_DIR}/compile_flag.cmake")
include (link_flag) include ("${CMAKE_CURRENT_LIST_DIR}/link_flag.cmake")
include (test_restrict) include ("${CMAKE_CURRENT_LIST_DIR}/test_restrict.cmake")
############################################################################### ###############################################################################
@ -52,7 +52,7 @@ endif ()
# try_compile( # try_compile(
# __nc_cxx_stdcxxfs ${CMAKE_CURRENT_BINARY_DIR} # __nc_cxx_stdcxxfs ${CMAKE_CURRENT_BINARY_DIR}
# SOURCES # SOURCES
# ${NC_CMAKE_BASE}/nc_cxx_stdcxxfs.cpp # ${CMAKE_CURRENT_LIST_DIR}/nc_cxx_stdcxxfs.cpp
# LINK_LIBRARIES # LINK_LIBRARIES
# ${lib} # ${lib}
# ) # )

View File

@ -7,9 +7,9 @@ set (__nc_optimisation TRUE)
############################################################################### ###############################################################################
include (compile_flag) include ("${CMAKE_CURRENT_LIST_DIR}/compile_flag.cmake")
include (link_flag) include ("${CMAKE_CURRENT_LIST_DIR}/link_flag.cmake")
include (canonical_host) include ("${CMAKE_CURRENT_LIST_DIR}/canonical_host.cmake")
############################################################################### ###############################################################################

View File

@ -7,8 +7,8 @@ set (__nc_platform TRUE)
############################################################################### ###############################################################################
include (compile_flag) include ("${CMAKE_CURRENT_LIST_DIR}/compile_flag.cmake")
include (link_flag) include ("${CMAKE_CURRENT_LIST_DIR}/link_flag.cmake")
############################################################################### ###############################################################################

View File

@ -7,7 +7,7 @@ set (__nc_warnings TRUE)
############################################################################### ###############################################################################
include (compile_flag) include ("${CMAKE_CURRENT_LIST_DIR}/compile_flag.cmake")
############################################################################### ###############################################################################

View File

@ -21,7 +21,7 @@ macro(search_libs _variable _symbol)
__search_libs_${_symbol} __search_libs_${_symbol}
"${CMAKE_BINARY_DIR}/CMakeTmp" "${CMAKE_BINARY_DIR}/CMakeTmp"
SOURCES SOURCES
"${NC_CMAKE_BASE}/search_libs.cpp" "${CMAKE_CURRENT_LIST_DIR}/search_libs.cpp"
COMPILE_DEFINITIONS COMPILE_DEFINITIONS
"-DSYMBOL=${_symbol}") "-DSYMBOL=${_symbol}")
@ -36,7 +36,7 @@ macro(search_libs _variable _symbol)
__search_libs_${_symbol} __search_libs_${_symbol}
"${CMAKE_BINARY_DIR}/CMakeTmp" "${CMAKE_BINARY_DIR}/CMakeTmp"
SOURCES SOURCES
"${NC_CMAKE_BASE}/search_libs.cpp" "${CMAKE_CURRENT_LIST_DIR}/search_libs.cpp"
LINK_LIBRARIES LINK_LIBRARIES
"${lib}" "${lib}"
COMPILE_DEFINITIONS COMPILE_DEFINITIONS

View File

@ -6,7 +6,7 @@ macro(test_restrict VARIABLE)
TRY_COMPILE( TRY_COMPILE(
TEST_${VARIABLE} TEST_${VARIABLE}
"${CMAKE_BINARY_DIR}/CMakeTmp" "${CMAKE_BINARY_DIR}/CMakeTmp"
SOURCES "${NC_CMAKE_BASE}/test_restrict.cpp" SOURCES "${CMAKE_CURRENT_LIST_DIR}/test_restrict.cpp"
COMPILE_DEFINITIONS "-DKEYWORD=${KEYWORD}") COMPILE_DEFINITIONS "-DKEYWORD=${KEYWORD}")
set(__test_restrict_last ${KEYWORD}) set(__test_restrict_last ${KEYWORD})
ENDIF (NOT TEST_${VARIABLE}) ENDIF (NOT TEST_${VARIABLE})