try to cache results as much as possible
This commit is contained in:
parent
566b98e5cb
commit
b389d86391
@ -1,5 +1,5 @@
|
|||||||
macro (canonical_host)
|
macro (canonical_host)
|
||||||
if (NOT __test_canonical_host)
|
if (NOT DEFINED host_cpu)
|
||||||
message (STATUS "checking the host CPU")
|
message (STATUS "checking the host CPU")
|
||||||
|
|
||||||
execute_process (
|
execute_process (
|
||||||
@ -12,10 +12,9 @@ macro (canonical_host)
|
|||||||
message (FATAL_ERROR "unable to query for canonical host")
|
message (FATAL_ERROR "unable to query for canonical host")
|
||||||
endif (${__canonical_host_result})
|
endif (${__canonical_host_result})
|
||||||
|
|
||||||
string(REGEX MATCH "^([^-\]+)" HOST_CPU ${__canonical_host_output})
|
string(REGEX MATCH "^([^-\]+)" host_cpu ${__canonical_host_output})
|
||||||
|
set (host_cpu "${host_cpu}" CACHE INTERNAL "host cpu type")
|
||||||
|
|
||||||
message (STATUS "checking the host CPU - found '${HOST_CPU}'")
|
message (STATUS "checking the host CPU - found '${host_cpu}'")
|
||||||
endif (NOT __test_canonical_host)
|
endif ()
|
||||||
|
|
||||||
set (__test_canonical_host 1 INTERNAL)
|
|
||||||
endmacro (canonical_host)
|
endmacro (canonical_host)
|
||||||
|
@ -3,11 +3,11 @@ include(CheckCXXCompilerFlag)
|
|||||||
macro (append_compile_flag _flag)
|
macro (append_compile_flag _flag)
|
||||||
string (MAKE_C_IDENTIFIER ${_flag} _name)
|
string (MAKE_C_IDENTIFIER ${_flag} _name)
|
||||||
|
|
||||||
if (NOT __append_compile_flag_${_name})
|
if (NOT DEFINED compile_flag_${_name})
|
||||||
check_cxx_compiler_flag (${_flag} __append_compile_flag_${_name})
|
check_cxx_compiler_flag (${_flag} compile_flag_${_name})
|
||||||
if (__append_compile_flag_${_name})
|
|
||||||
set (CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} ${_flag}")
|
|
||||||
set (__append_compile_flag_${_name} 1 INTERNAL)
|
|
||||||
endif ()
|
|
||||||
endif ()
|
endif ()
|
||||||
|
|
||||||
|
if (compile_flag_${_name})
|
||||||
|
set (CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} ${_flag}")
|
||||||
|
endif()
|
||||||
endmacro(append_compile_flag)
|
endmacro(append_compile_flag)
|
||||||
|
@ -1,25 +1,36 @@
|
|||||||
macro(check_link_flag variable flag)
|
macro(check_link_flag _variable _flag)
|
||||||
message (STATUS "checking linker flag ${flag}")
|
string (MAKE_C_IDENTIFIER ${_flag} _name)
|
||||||
|
|
||||||
set (__check_linker_flag_old "${CMAKE_EXE_LINKER_FLAGS}" INTERNAL)
|
if (NOT DEFINED __check_link_flag_${_name})
|
||||||
set (CMAKE_EXE_LINKER_FLAGS "${CMAKE_EXE_LINKER_FLAGS} ${flag}")
|
message (STATUS "checking linker flag ${_flag}")
|
||||||
|
|
||||||
try_compile (test_check_linker_flag
|
set (__check_linker_flag_old "${CMAKE_EXE_LINKER_FLAGS}" INTERNAL)
|
||||||
"${CMAKE_CURRENT_BINARY_DIR}/CMakeTmp"
|
set (CMAKE_EXE_LINKER_FLAGS "${CMAKE_EXE_LINKER_FLAGS} ${_flag}")
|
||||||
SOURCES "${CMAKE_CURRENT_SOURCE_DIR}/cmake/test_link_flag.cpp")
|
|
||||||
if (test_check_linker_flag)
|
try_compile (
|
||||||
message (STATUS "checking linker flag ${flag} - found")
|
__check_link_flag_${_name}
|
||||||
set (${variable} 1)
|
"${CMAKE_CURRENT_BINARY_DIR}/CMakeTmp"
|
||||||
else(test_check_linker_flag)
|
SOURCES
|
||||||
message (STATUS "checking linker flag ${flag} - not found")
|
"${CMAKE_CURRENT_SOURCE_DIR}/cmake/test_link_flag.cpp")
|
||||||
set (${variable} 0)
|
|
||||||
endif(test_check_linker_flag)
|
if (__check_link_flag_${_name})
|
||||||
|
message (STATUS "checking linker flag ${_flag} - found")
|
||||||
|
else()
|
||||||
|
message (STATUS "checking linker flag ${_flag} - not found")
|
||||||
|
endif()
|
||||||
|
endif ()
|
||||||
|
|
||||||
|
if (__check_link_flag_${_name})
|
||||||
|
set (${variable} 1 INTERNAL)
|
||||||
|
else()
|
||||||
|
set (${variable} 0 INTERNAL)
|
||||||
|
endif()
|
||||||
endmacro()
|
endmacro()
|
||||||
|
|
||||||
|
|
||||||
macro(append_link_flag flag)
|
macro(append_link_flag flag)
|
||||||
check_link_flag (__test_link_flag_${flag} ${flag})
|
check_link_flag (__test_link_flag_${flag} ${flag})
|
||||||
if (__test_link_flag_${flag})
|
if (__test_link_flag_${_flag})
|
||||||
set (CMAKE_EXE_LINKER_FLAGS "${__append_link_flag_old}")
|
set (CMAKE_EXE_LINKER_FLAGS "${CMAKE_EXE_LINKER_FLAGS} ${_flag}")
|
||||||
endif()
|
endif()
|
||||||
endmacro()
|
endmacro()
|
||||||
|
30
nc_cxx.cmake
30
nc_cxx.cmake
@ -3,7 +3,7 @@ include (test_restrict)
|
|||||||
|
|
||||||
|
|
||||||
###############################################################################
|
###############################################################################
|
||||||
append_compile_flag (-std=c++1z)
|
set (CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -std=c++1z -fpermissive")
|
||||||
|
|
||||||
|
|
||||||
###############################################################################
|
###############################################################################
|
||||||
@ -13,16 +13,28 @@ append_compile_flag (-std=c++1z)
|
|||||||
# hardcoded guess and doesn't respect _all_ the system paths; specifically
|
# hardcoded guess and doesn't respect _all_ the system paths; specifically
|
||||||
# something like /usr/lib/gcc/x86_64-pc-linux-gnu/6.3.0/libstdc++.so won't get
|
# something like /usr/lib/gcc/x86_64-pc-linux-gnu/6.3.0/libstdc++.so won't get
|
||||||
# discovered.
|
# discovered.
|
||||||
foreach(lib "" stdc++fs)
|
if (NOT DEFINED __nc_cxx_stdcxxfs)
|
||||||
if (NOT __nc_cxx_stdcxxfs)
|
foreach(lib "" stdc++fs)
|
||||||
try_compile(__nc_cxx_stdcxxfs ${CMAKE_CURRENT_BINARY_DIR}
|
if (NOT __nc_cxx_stdcxxfs)
|
||||||
SOURCES ${CMAKE_CURRENT_SOURCE_DIR}/cmake/nc_cxx_stdcxxfs.cpp
|
try_compile(
|
||||||
LINK_LIBRARIES ${lib})
|
__nc_cxx_stdcxxfs ${CMAKE_CURRENT_BINARY_DIR}
|
||||||
if (__nc_cxx_stdcxxfs)
|
SOURCES
|
||||||
list (APPEND LIBS ${lib})
|
${CMAKE_CURRENT_SOURCE_DIR}/cmake/nc_cxx_stdcxxfs.cpp
|
||||||
|
LINK_LIBRARIES
|
||||||
|
${lib})
|
||||||
|
|
||||||
|
if (__nc_cxx_stdcxxfs)
|
||||||
|
set (__nc_cxx_stdcxxfs "${lib}" CACHE INTERNAL "library required for c++ filesystem")
|
||||||
|
endif ()
|
||||||
endif ()
|
endif ()
|
||||||
|
endforeach()
|
||||||
|
|
||||||
|
if (NOT __nc_cxx_stdcxxfs)
|
||||||
|
set (__nc_cxx_stdcxxfs)
|
||||||
endif ()
|
endif ()
|
||||||
endforeach()
|
endif ()
|
||||||
|
|
||||||
|
list (APPEND LIBS ${__nc_cxx_stdcxxfs})
|
||||||
|
|
||||||
|
|
||||||
###############################################################################
|
###############################################################################
|
||||||
|
@ -31,18 +31,18 @@ canonical_host()
|
|||||||
|
|
||||||
|
|
||||||
##-----------------------------------------------------------------------------
|
##-----------------------------------------------------------------------------
|
||||||
if (${HOST_CPU} STREQUAL "x86_64")
|
if (${host_cpu} STREQUAL "x86_64")
|
||||||
append_compile_flag(-mtune=generic)
|
append_compile_flag(-mtune=generic)
|
||||||
append_compile_flag(-msse)
|
append_compile_flag(-msse)
|
||||||
append_compile_flag(-msse2)
|
append_compile_flag(-msse2)
|
||||||
append_compile_flag(-msahf)
|
append_compile_flag(-msahf)
|
||||||
elseif (${HOST_CPU} STREQUAL "i686")
|
elseif (${host_cpu} STREQUAL "i686")
|
||||||
append_compile_flag(-march=prescott)
|
append_compile_flag(-march=prescott)
|
||||||
append_compile_flag(-mtune=generic)
|
append_compile_flag(-mtune=generic)
|
||||||
append_compile_flag(-mcmov)
|
append_compile_flag(-mcmov)
|
||||||
append_compile_flag(-mfpmath=sse)
|
append_compile_flag(-mfpmath=sse)
|
||||||
else ()
|
else ()
|
||||||
message (FATAL_ERROR "unknown HOST_CPU '${HOST_CPU}'")
|
message (FATAL_ERROR "unknown HOST_CPU '${host_cpu}'")
|
||||||
endif ()
|
endif ()
|
||||||
|
|
||||||
|
|
||||||
|
@ -1,39 +1,47 @@
|
|||||||
# search a list of libraries for a given (C linkage) _symbol. returns the
|
|
||||||
# required library in _variable, and defines HAVE_SYMBOL if it was found.
|
|
||||||
macro(search_libs _variable _symbol)
|
macro(search_libs _variable _symbol)
|
||||||
message (STATUS "searching for ${_symbol}")
|
if (NOT DEFINED __search_libs_${_symbol})
|
||||||
|
message (STATUS "searching for ${_symbol}")
|
||||||
|
|
||||||
try_compile(
|
if (NOT DEFINED __search_libs_${_symbol}_lib)
|
||||||
__search_libs_${_symbol}
|
try_compile(
|
||||||
"${CMAKE_BINARY_DIR}/CMakeTmp"
|
__search_libs_${_symbol}
|
||||||
SOURCES "${CMAKE_SOURCE_DIR}/cmake/search_libs.cpp"
|
"${CMAKE_BINARY_DIR}/CMakeTmp"
|
||||||
COMPILE_DEFINITIONS "-DSYMBOL=${_symbol}")
|
SOURCES
|
||||||
|
"${CMAKE_SOURCE_DIR}/cmake/search_libs.cpp"
|
||||||
|
COMPILE_DEFINITIONS
|
||||||
|
"-DSYMBOL=${_symbol}")
|
||||||
|
|
||||||
if (NOT __search_libs_${_symbol})
|
if (__search_libs_${_symbol})
|
||||||
foreach (lib ${ARGN})
|
set (__search_libs_${_symbol}_lib)
|
||||||
if (NOT __search_libs_${_symbol}_last)
|
else ()
|
||||||
message (STATUS "searching for ${_symbol} in ${lib}")
|
foreach (lib ${ARGN})
|
||||||
try_compile(
|
if (NOT __search_libs_${_symbol})
|
||||||
__search_libs_${_symbol}
|
message (STATUS "searching for ${_symbol} in ${lib}")
|
||||||
"${CMAKE_BINARY_DIR}/CMakeTmp"
|
|
||||||
SOURCES "${CMAKE_SOURCE_DIR}/cmake/search_libs.cpp"
|
try_compile(
|
||||||
LINK_LIBRARIES "-l${lib}"
|
__search_libs_${_symbol}
|
||||||
COMPILE_DEFINITIONS "-DSYMBOL=${_symbol}")
|
"${CMAKE_BINARY_DIR}/CMakeTmp"
|
||||||
set (__search_libs_${_symbol}_last ${lib})
|
SOURCES
|
||||||
|
"${CMAKE_SOURCE_DIR}/cmake/search_libs.cpp"
|
||||||
|
LINK_LIBRARIES
|
||||||
|
"${lib}"
|
||||||
|
COMPILE_DEFINITIONS
|
||||||
|
"-DSYMBOL=${_symbol}")
|
||||||
|
|
||||||
|
if (__search_libs_${_symbol})
|
||||||
|
set (__search_libs_${_symbol}_lib ${lib} CACHE INTERNAL "library exposing ${_symbol}")
|
||||||
|
endif ()
|
||||||
|
endif ()
|
||||||
|
endforeach()
|
||||||
endif ()
|
endif ()
|
||||||
endforeach()
|
|
||||||
endif()
|
|
||||||
|
|
||||||
if (__search_libs_${_symbol})
|
|
||||||
if (__search_libs_${_symbol}_last)
|
|
||||||
message (STATUS "searching for ${_symbol} - found (in ${__search_libs_${_symbol}_last})")
|
|
||||||
else ()
|
|
||||||
message (STATUS "searching for ${_symbol} - found")
|
|
||||||
endif ()
|
endif ()
|
||||||
set (${_variable} __search_libs_${_symbol}_last)
|
|
||||||
string (TOUPPER ${_symbol} upper_symbol)
|
if (__search_libs_${_symbol})
|
||||||
set (HAVE_${upper_symbol} 1)
|
message (STATUS "searching for ${_symbol} - found")
|
||||||
else ()
|
else ()
|
||||||
message (STATUS "searching for ${_symbol} - not found")
|
message (STATUS "searching for ${_symbol} - not found")
|
||||||
|
endif()
|
||||||
endif ()
|
endif ()
|
||||||
|
|
||||||
|
set (${_variable} ${__search_libs_${_symbol}_lib})
|
||||||
endmacro()
|
endmacro()
|
||||||
|
Loading…
Reference in New Issue
Block a user