nc: set a variable to point to this directory

This commit is contained in:
Danny Robson 2019-06-18 11:28:17 +10:00
parent e46716472a
commit 93b876dee7
4 changed files with 18 additions and 4 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
"${CMAKE_CURRENT_SOURCE_DIR}/cmake/test_link_flag.cpp") "${NC_CMAKE_BASE}/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,6 +13,20 @@ 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
# 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})
message (STATUS testing nc_cmake_base at "${d}")
if (EXISTS "${d}/nc.cmake")
set (NC_CMAKE_BASE "${d}")
message (STATUS testing nc_cmake_base at "${d} - found")
break()
else ()
message (STATUS testing nc_cmake_base at "${d} - not found")
endif ()
endforeach()
include (nc_cxx) include (nc_cxx)
include (nc_sanitizer) include (nc_sanitizer)
include (nc_platform) include (nc_platform)

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
"${CMAKE_SOURCE_DIR}/cmake/search_libs.cpp" "${NC_CMAKE_BASE}/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
"${CMAKE_SOURCE_DIR}/cmake/search_libs.cpp" "${NC_CMAKE_BASE}/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 "${CMAKE_SOURCE_DIR}/cmake/test_restrict.cpp" SOURCES "${NC_CMAKE_BASE}/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})