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:
parent
b09ea14d5a
commit
54f0855312
@ -12,7 +12,7 @@ macro(check_link_flag _variable _flag)
|
||||
__check_link_flag_${_name}
|
||||
"${CMAKE_CURRENT_BINARY_DIR}/CMakeTmp"
|
||||
SOURCES
|
||||
"${NC_CMAKE_BASE}/test_link_flag.cpp")
|
||||
"${CMAKE_CURRENT_LIST_DIR}/test_link_flag.cpp")
|
||||
|
||||
if (__check_link_flag_${_name})
|
||||
message (STATUS "checking linker flag ${_flag} - found")
|
||||
|
24
nc.cmake
24
nc.cmake
@ -13,22 +13,8 @@ set (THREADS_PREFER_PTHREAD_FLAG ON)
|
||||
find_package (Threads REQUIRED)
|
||||
link_libraries (Threads::Threads)
|
||||
|
||||
# Set the variable NC_CMAKE_BASE to the root path of this collection of cmake
|
||||
# files so that we can reliably point to soure files contained therein
|
||||
# (eg, the search_lib.cpp tests and friends).
|
||||
foreach (d ${CMAKE_MODULE_PATH})
|
||||
if (EXISTS "${d}/nc.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)
|
||||
include ("${CMAKE_CURRENT_LIST_DIR}/nc_cxx.cmake")
|
||||
include ("${CMAKE_CURRENT_LIST_DIR}/nc_sanitizer.cmake")
|
||||
include ("${CMAKE_CURRENT_LIST_DIR}/nc_platform.cmake")
|
||||
include ("${CMAKE_CURRENT_LIST_DIR}/nc_optimisation.cmake")
|
||||
include ("${CMAKE_CURRENT_LIST_DIR}/nc_warnings.cmake")
|
||||
|
@ -15,9 +15,9 @@ set (CMAKE_C_FLAGS_DEBUG "")
|
||||
|
||||
|
||||
###############################################################################
|
||||
include (compile_flag)
|
||||
include (link_flag)
|
||||
include (test_restrict)
|
||||
include ("${CMAKE_CURRENT_LIST_DIR}/compile_flag.cmake")
|
||||
include ("${CMAKE_CURRENT_LIST_DIR}/link_flag.cmake")
|
||||
include ("${CMAKE_CURRENT_LIST_DIR}/test_restrict.cmake")
|
||||
|
||||
|
||||
###############################################################################
|
||||
@ -52,7 +52,7 @@ endif ()
|
||||
# try_compile(
|
||||
# __nc_cxx_stdcxxfs ${CMAKE_CURRENT_BINARY_DIR}
|
||||
# SOURCES
|
||||
# ${NC_CMAKE_BASE}/nc_cxx_stdcxxfs.cpp
|
||||
# ${CMAKE_CURRENT_LIST_DIR}/nc_cxx_stdcxxfs.cpp
|
||||
# LINK_LIBRARIES
|
||||
# ${lib}
|
||||
# )
|
||||
|
@ -7,9 +7,9 @@ set (__nc_optimisation TRUE)
|
||||
|
||||
|
||||
###############################################################################
|
||||
include (compile_flag)
|
||||
include (link_flag)
|
||||
include (canonical_host)
|
||||
include ("${CMAKE_CURRENT_LIST_DIR}/compile_flag.cmake")
|
||||
include ("${CMAKE_CURRENT_LIST_DIR}/link_flag.cmake")
|
||||
include ("${CMAKE_CURRENT_LIST_DIR}/canonical_host.cmake")
|
||||
|
||||
|
||||
###############################################################################
|
||||
|
@ -7,8 +7,8 @@ set (__nc_platform TRUE)
|
||||
|
||||
|
||||
###############################################################################
|
||||
include (compile_flag)
|
||||
include (link_flag)
|
||||
include ("${CMAKE_CURRENT_LIST_DIR}/compile_flag.cmake")
|
||||
include ("${CMAKE_CURRENT_LIST_DIR}/link_flag.cmake")
|
||||
|
||||
|
||||
###############################################################################
|
||||
|
@ -7,7 +7,7 @@ set (__nc_warnings TRUE)
|
||||
|
||||
|
||||
###############################################################################
|
||||
include (compile_flag)
|
||||
include ("${CMAKE_CURRENT_LIST_DIR}/compile_flag.cmake")
|
||||
|
||||
|
||||
###############################################################################
|
||||
|
@ -21,7 +21,7 @@ macro(search_libs _variable _symbol)
|
||||
__search_libs_${_symbol}
|
||||
"${CMAKE_BINARY_DIR}/CMakeTmp"
|
||||
SOURCES
|
||||
"${NC_CMAKE_BASE}/search_libs.cpp"
|
||||
"${CMAKE_CURRENT_LIST_DIR}/search_libs.cpp"
|
||||
COMPILE_DEFINITIONS
|
||||
"-DSYMBOL=${_symbol}")
|
||||
|
||||
@ -36,7 +36,7 @@ macro(search_libs _variable _symbol)
|
||||
__search_libs_${_symbol}
|
||||
"${CMAKE_BINARY_DIR}/CMakeTmp"
|
||||
SOURCES
|
||||
"${NC_CMAKE_BASE}/search_libs.cpp"
|
||||
"${CMAKE_CURRENT_LIST_DIR}/search_libs.cpp"
|
||||
LINK_LIBRARIES
|
||||
"${lib}"
|
||||
COMPILE_DEFINITIONS
|
||||
|
@ -6,7 +6,7 @@ macro(test_restrict VARIABLE)
|
||||
TRY_COMPILE(
|
||||
TEST_${VARIABLE}
|
||||
"${CMAKE_BINARY_DIR}/CMakeTmp"
|
||||
SOURCES "${NC_CMAKE_BASE}/test_restrict.cpp"
|
||||
SOURCES "${CMAKE_CURRENT_LIST_DIR}/test_restrict.cpp"
|
||||
COMPILE_DEFINITIONS "-DKEYWORD=${KEYWORD}")
|
||||
set(__test_restrict_last ${KEYWORD})
|
||||
ENDIF (NOT TEST_${VARIABLE})
|
||||
|
Loading…
Reference in New Issue
Block a user