Merge topic 'try_compile-targets'
236133e
Handle targets in the LINK_LIBRARIES of try_compile.1c0597c
Add a new Export generator for IMPORTED targets.f2ab17d
Keep track of all targets seen while evaluating a genex.
This commit is contained in:
commit
b887bca6ee
|
@ -24,7 +24,6 @@
|
||||||
# (To distribute this file outside of CMake, substitute the full
|
# (To distribute this file outside of CMake, substitute the full
|
||||||
# License text for the above reference.)
|
# License text for the above reference.)
|
||||||
|
|
||||||
include("${CMAKE_CURRENT_LIST_DIR}/CMakeExpandImportedTargets.cmake")
|
|
||||||
|
|
||||||
|
|
||||||
macro(CHECK_C_SOURCE_COMPILES SOURCE VAR)
|
macro(CHECK_C_SOURCE_COMPILES SOURCE VAR)
|
||||||
|
@ -43,10 +42,8 @@ macro(CHECK_C_SOURCE_COMPILES SOURCE VAR)
|
||||||
set(MACRO_CHECK_FUNCTION_DEFINITIONS
|
set(MACRO_CHECK_FUNCTION_DEFINITIONS
|
||||||
"-D${VAR} ${CMAKE_REQUIRED_FLAGS}")
|
"-D${VAR} ${CMAKE_REQUIRED_FLAGS}")
|
||||||
if(CMAKE_REQUIRED_LIBRARIES)
|
if(CMAKE_REQUIRED_LIBRARIES)
|
||||||
# this one translates potentially used imported library targets to their files on disk
|
|
||||||
CMAKE_EXPAND_IMPORTED_TARGETS(_ADJUSTED_CMAKE_REQUIRED_LIBRARIES LIBRARIES ${CMAKE_REQUIRED_LIBRARIES} CONFIGURATION "${CMAKE_TRY_COMPILE_CONFIGURATION}")
|
|
||||||
set(CHECK_C_SOURCE_COMPILES_ADD_LIBRARIES
|
set(CHECK_C_SOURCE_COMPILES_ADD_LIBRARIES
|
||||||
"-DLINK_LIBRARIES:STRING=${_ADJUSTED_CMAKE_REQUIRED_LIBRARIES}")
|
LINK_LIBRARIES ${CMAKE_REQUIRED_LIBRARIES})
|
||||||
else()
|
else()
|
||||||
set(CHECK_C_SOURCE_COMPILES_ADD_LIBRARIES)
|
set(CHECK_C_SOURCE_COMPILES_ADD_LIBRARIES)
|
||||||
endif()
|
endif()
|
||||||
|
@ -64,8 +61,8 @@ macro(CHECK_C_SOURCE_COMPILES SOURCE VAR)
|
||||||
${CMAKE_BINARY_DIR}
|
${CMAKE_BINARY_DIR}
|
||||||
${CMAKE_BINARY_DIR}${CMAKE_FILES_DIRECTORY}/CMakeTmp/src.c
|
${CMAKE_BINARY_DIR}${CMAKE_FILES_DIRECTORY}/CMakeTmp/src.c
|
||||||
COMPILE_DEFINITIONS ${CMAKE_REQUIRED_DEFINITIONS}
|
COMPILE_DEFINITIONS ${CMAKE_REQUIRED_DEFINITIONS}
|
||||||
|
${CHECK_C_SOURCE_COMPILES_ADD_LIBRARIES}
|
||||||
CMAKE_FLAGS -DCOMPILE_DEFINITIONS:STRING=${MACRO_CHECK_FUNCTION_DEFINITIONS}
|
CMAKE_FLAGS -DCOMPILE_DEFINITIONS:STRING=${MACRO_CHECK_FUNCTION_DEFINITIONS}
|
||||||
"${CHECK_C_SOURCE_COMPILES_ADD_LIBRARIES}"
|
|
||||||
"${CHECK_C_SOURCE_COMPILES_ADD_INCLUDES}"
|
"${CHECK_C_SOURCE_COMPILES_ADD_INCLUDES}"
|
||||||
OUTPUT_VARIABLE OUTPUT)
|
OUTPUT_VARIABLE OUTPUT)
|
||||||
|
|
||||||
|
|
|
@ -24,7 +24,6 @@
|
||||||
# (To distribute this file outside of CMake, substitute the full
|
# (To distribute this file outside of CMake, substitute the full
|
||||||
# License text for the above reference.)
|
# License text for the above reference.)
|
||||||
|
|
||||||
include("${CMAKE_CURRENT_LIST_DIR}/CMakeExpandImportedTargets.cmake")
|
|
||||||
|
|
||||||
|
|
||||||
macro(CHECK_C_SOURCE_RUNS SOURCE VAR)
|
macro(CHECK_C_SOURCE_RUNS SOURCE VAR)
|
||||||
|
@ -32,10 +31,8 @@ macro(CHECK_C_SOURCE_RUNS SOURCE VAR)
|
||||||
set(MACRO_CHECK_FUNCTION_DEFINITIONS
|
set(MACRO_CHECK_FUNCTION_DEFINITIONS
|
||||||
"-D${VAR} ${CMAKE_REQUIRED_FLAGS}")
|
"-D${VAR} ${CMAKE_REQUIRED_FLAGS}")
|
||||||
if(CMAKE_REQUIRED_LIBRARIES)
|
if(CMAKE_REQUIRED_LIBRARIES)
|
||||||
# this one translates potentially used imported library targets to their files on disk
|
|
||||||
CMAKE_EXPAND_IMPORTED_TARGETS(_ADJUSTED_CMAKE_REQUIRED_LIBRARIES LIBRARIES ${CMAKE_REQUIRED_LIBRARIES} CONFIGURATION "${CMAKE_TRY_COMPILE_CONFIGURATION}")
|
|
||||||
set(CHECK_C_SOURCE_COMPILES_ADD_LIBRARIES
|
set(CHECK_C_SOURCE_COMPILES_ADD_LIBRARIES
|
||||||
"-DLINK_LIBRARIES:STRING=${_ADJUSTED_CMAKE_REQUIRED_LIBRARIES}")
|
LINK_LIBRARIES ${CMAKE_REQUIRED_LIBRARIES})
|
||||||
else()
|
else()
|
||||||
set(CHECK_C_SOURCE_COMPILES_ADD_LIBRARIES)
|
set(CHECK_C_SOURCE_COMPILES_ADD_LIBRARIES)
|
||||||
endif()
|
endif()
|
||||||
|
@ -53,9 +50,9 @@ macro(CHECK_C_SOURCE_RUNS SOURCE VAR)
|
||||||
${CMAKE_BINARY_DIR}
|
${CMAKE_BINARY_DIR}
|
||||||
${CMAKE_BINARY_DIR}${CMAKE_FILES_DIRECTORY}/CMakeTmp/src.c
|
${CMAKE_BINARY_DIR}${CMAKE_FILES_DIRECTORY}/CMakeTmp/src.c
|
||||||
COMPILE_DEFINITIONS ${CMAKE_REQUIRED_DEFINITIONS}
|
COMPILE_DEFINITIONS ${CMAKE_REQUIRED_DEFINITIONS}
|
||||||
|
${CHECK_C_SOURCE_COMPILES_ADD_LIBRARIES}
|
||||||
CMAKE_FLAGS -DCOMPILE_DEFINITIONS:STRING=${MACRO_CHECK_FUNCTION_DEFINITIONS}
|
CMAKE_FLAGS -DCOMPILE_DEFINITIONS:STRING=${MACRO_CHECK_FUNCTION_DEFINITIONS}
|
||||||
-DCMAKE_SKIP_RPATH:BOOL=${CMAKE_SKIP_RPATH}
|
-DCMAKE_SKIP_RPATH:BOOL=${CMAKE_SKIP_RPATH}
|
||||||
"${CHECK_C_SOURCE_COMPILES_ADD_LIBRARIES}"
|
|
||||||
"${CHECK_C_SOURCE_COMPILES_ADD_INCLUDES}"
|
"${CHECK_C_SOURCE_COMPILES_ADD_INCLUDES}"
|
||||||
COMPILE_OUTPUT_VARIABLE OUTPUT)
|
COMPILE_OUTPUT_VARIABLE OUTPUT)
|
||||||
# if it did not compile make the return value fail code of 1
|
# if it did not compile make the return value fail code of 1
|
||||||
|
|
|
@ -24,7 +24,6 @@
|
||||||
# (To distribute this file outside of CMake, substitute the full
|
# (To distribute this file outside of CMake, substitute the full
|
||||||
# License text for the above reference.)
|
# License text for the above reference.)
|
||||||
|
|
||||||
include("${CMAKE_CURRENT_LIST_DIR}/CMakeExpandImportedTargets.cmake")
|
|
||||||
|
|
||||||
|
|
||||||
macro(CHECK_CXX_SOURCE_COMPILES SOURCE VAR)
|
macro(CHECK_CXX_SOURCE_COMPILES SOURCE VAR)
|
||||||
|
@ -44,10 +43,8 @@ macro(CHECK_CXX_SOURCE_COMPILES SOURCE VAR)
|
||||||
set(MACRO_CHECK_FUNCTION_DEFINITIONS
|
set(MACRO_CHECK_FUNCTION_DEFINITIONS
|
||||||
"-D${VAR} ${CMAKE_REQUIRED_FLAGS}")
|
"-D${VAR} ${CMAKE_REQUIRED_FLAGS}")
|
||||||
if(CMAKE_REQUIRED_LIBRARIES)
|
if(CMAKE_REQUIRED_LIBRARIES)
|
||||||
# this one translates potentially used imported library targets to their files on disk
|
|
||||||
CMAKE_EXPAND_IMPORTED_TARGETS(_ADJUSTED_CMAKE_REQUIRED_LIBRARIES LIBRARIES ${CMAKE_REQUIRED_LIBRARIES} CONFIGURATION "${CMAKE_TRY_COMPILE_CONFIGURATION}")
|
|
||||||
set(CHECK_CXX_SOURCE_COMPILES_ADD_LIBRARIES
|
set(CHECK_CXX_SOURCE_COMPILES_ADD_LIBRARIES
|
||||||
"-DLINK_LIBRARIES:STRING=${_ADJUSTED_CMAKE_REQUIRED_LIBRARIES}")
|
LINK_LIBRARIES ${CMAKE_REQUIRED_LIBRARIES})
|
||||||
else()
|
else()
|
||||||
set(CHECK_CXX_SOURCE_COMPILES_ADD_LIBRARIES)
|
set(CHECK_CXX_SOURCE_COMPILES_ADD_LIBRARIES)
|
||||||
endif()
|
endif()
|
||||||
|
@ -65,8 +62,8 @@ macro(CHECK_CXX_SOURCE_COMPILES SOURCE VAR)
|
||||||
${CMAKE_BINARY_DIR}
|
${CMAKE_BINARY_DIR}
|
||||||
${CMAKE_BINARY_DIR}${CMAKE_FILES_DIRECTORY}/CMakeTmp/src.cxx
|
${CMAKE_BINARY_DIR}${CMAKE_FILES_DIRECTORY}/CMakeTmp/src.cxx
|
||||||
COMPILE_DEFINITIONS ${CMAKE_REQUIRED_DEFINITIONS}
|
COMPILE_DEFINITIONS ${CMAKE_REQUIRED_DEFINITIONS}
|
||||||
|
${CHECK_CXX_SOURCE_COMPILES_ADD_LIBRARIES}
|
||||||
CMAKE_FLAGS -DCOMPILE_DEFINITIONS:STRING=${MACRO_CHECK_FUNCTION_DEFINITIONS}
|
CMAKE_FLAGS -DCOMPILE_DEFINITIONS:STRING=${MACRO_CHECK_FUNCTION_DEFINITIONS}
|
||||||
"${CHECK_CXX_SOURCE_COMPILES_ADD_LIBRARIES}"
|
|
||||||
"${CHECK_CXX_SOURCE_COMPILES_ADD_INCLUDES}"
|
"${CHECK_CXX_SOURCE_COMPILES_ADD_INCLUDES}"
|
||||||
OUTPUT_VARIABLE OUTPUT)
|
OUTPUT_VARIABLE OUTPUT)
|
||||||
|
|
||||||
|
|
|
@ -24,7 +24,6 @@
|
||||||
# (To distribute this file outside of CMake, substitute the full
|
# (To distribute this file outside of CMake, substitute the full
|
||||||
# License text for the above reference.)
|
# License text for the above reference.)
|
||||||
|
|
||||||
include("${CMAKE_CURRENT_LIST_DIR}/CMakeExpandImportedTargets.cmake")
|
|
||||||
|
|
||||||
|
|
||||||
macro(CHECK_CXX_SOURCE_RUNS SOURCE VAR)
|
macro(CHECK_CXX_SOURCE_RUNS SOURCE VAR)
|
||||||
|
@ -32,10 +31,8 @@ macro(CHECK_CXX_SOURCE_RUNS SOURCE VAR)
|
||||||
set(MACRO_CHECK_FUNCTION_DEFINITIONS
|
set(MACRO_CHECK_FUNCTION_DEFINITIONS
|
||||||
"-D${VAR} ${CMAKE_REQUIRED_FLAGS}")
|
"-D${VAR} ${CMAKE_REQUIRED_FLAGS}")
|
||||||
if(CMAKE_REQUIRED_LIBRARIES)
|
if(CMAKE_REQUIRED_LIBRARIES)
|
||||||
# this one translates potentially used imported library targets to their files on disk
|
|
||||||
CMAKE_EXPAND_IMPORTED_TARGETS(_ADJUSTED_CMAKE_REQUIRED_LIBRARIES LIBRARIES ${CMAKE_REQUIRED_LIBRARIES} CONFIGURATION "${CMAKE_TRY_COMPILE_CONFIGURATION}")
|
|
||||||
set(CHECK_CXX_SOURCE_COMPILES_ADD_LIBRARIES
|
set(CHECK_CXX_SOURCE_COMPILES_ADD_LIBRARIES
|
||||||
"-DLINK_LIBRARIES:STRING=${_ADJUSTED_CMAKE_REQUIRED_LIBRARIES}")
|
LINK_LIBRARIES ${CMAKE_REQUIRED_LIBRARIES})
|
||||||
else()
|
else()
|
||||||
set(CHECK_CXX_SOURCE_COMPILES_ADD_LIBRARIES)
|
set(CHECK_CXX_SOURCE_COMPILES_ADD_LIBRARIES)
|
||||||
endif()
|
endif()
|
||||||
|
@ -53,9 +50,9 @@ macro(CHECK_CXX_SOURCE_RUNS SOURCE VAR)
|
||||||
${CMAKE_BINARY_DIR}
|
${CMAKE_BINARY_DIR}
|
||||||
${CMAKE_BINARY_DIR}${CMAKE_FILES_DIRECTORY}/CMakeTmp/src.cxx
|
${CMAKE_BINARY_DIR}${CMAKE_FILES_DIRECTORY}/CMakeTmp/src.cxx
|
||||||
COMPILE_DEFINITIONS ${CMAKE_REQUIRED_DEFINITIONS}
|
COMPILE_DEFINITIONS ${CMAKE_REQUIRED_DEFINITIONS}
|
||||||
|
${CHECK_CXX_SOURCE_COMPILES_ADD_LIBRARIES}
|
||||||
CMAKE_FLAGS -DCOMPILE_DEFINITIONS:STRING=${MACRO_CHECK_FUNCTION_DEFINITIONS}
|
CMAKE_FLAGS -DCOMPILE_DEFINITIONS:STRING=${MACRO_CHECK_FUNCTION_DEFINITIONS}
|
||||||
-DCMAKE_SKIP_RPATH:BOOL=${CMAKE_SKIP_RPATH}
|
-DCMAKE_SKIP_RPATH:BOOL=${CMAKE_SKIP_RPATH}
|
||||||
"${CHECK_CXX_SOURCE_COMPILES_ADD_LIBRARIES}"
|
|
||||||
"${CHECK_CXX_SOURCE_COMPILES_ADD_INCLUDES}"
|
"${CHECK_CXX_SOURCE_COMPILES_ADD_INCLUDES}"
|
||||||
COMPILE_OUTPUT_VARIABLE OUTPUT)
|
COMPILE_OUTPUT_VARIABLE OUTPUT)
|
||||||
|
|
||||||
|
|
|
@ -22,17 +22,14 @@
|
||||||
# (To distribute this file outside of CMake, substitute the full
|
# (To distribute this file outside of CMake, substitute the full
|
||||||
# License text for the above reference.)
|
# License text for the above reference.)
|
||||||
|
|
||||||
include("${CMAKE_CURRENT_LIST_DIR}/CMakeExpandImportedTargets.cmake")
|
|
||||||
|
|
||||||
|
|
||||||
macro(CHECK_FORTRAN_FUNCTION_EXISTS FUNCTION VARIABLE)
|
macro(CHECK_FORTRAN_FUNCTION_EXISTS FUNCTION VARIABLE)
|
||||||
if(NOT DEFINED ${VARIABLE})
|
if(NOT DEFINED ${VARIABLE})
|
||||||
message(STATUS "Looking for Fortran ${FUNCTION}")
|
message(STATUS "Looking for Fortran ${FUNCTION}")
|
||||||
if(CMAKE_REQUIRED_LIBRARIES)
|
if(CMAKE_REQUIRED_LIBRARIES)
|
||||||
# this one translates potentially used imported library targets to their files on disk
|
|
||||||
cmake_expand_imported_targets(_ADJUSTED_CMAKE_REQUIRED_LIBRARIES LIBRARIES ${CMAKE_REQUIRED_LIBRARIES} CONFIGURATION "${CMAKE_TRY_COMPILE_CONFIGURATION}")
|
|
||||||
set(CHECK_FUNCTION_EXISTS_ADD_LIBRARIES
|
set(CHECK_FUNCTION_EXISTS_ADD_LIBRARIES
|
||||||
"-DLINK_LIBRARIES:STRING=${_ADJUSTED_CMAKE_REQUIRED_LIBRARIES}")
|
LINK_LIBRARIES ${CMAKE_REQUIRED_LIBRARIES})
|
||||||
else()
|
else()
|
||||||
set(CHECK_FUNCTION_EXISTS_ADD_LIBRARIES)
|
set(CHECK_FUNCTION_EXISTS_ADD_LIBRARIES)
|
||||||
endif()
|
endif()
|
||||||
|
@ -48,7 +45,7 @@ macro(CHECK_FORTRAN_FUNCTION_EXISTS FUNCTION VARIABLE)
|
||||||
try_compile(${VARIABLE}
|
try_compile(${VARIABLE}
|
||||||
${CMAKE_BINARY_DIR}
|
${CMAKE_BINARY_DIR}
|
||||||
${CMAKE_BINARY_DIR}${CMAKE_FILES_DIRECTORY}/CMakeTmp/testFortranCompiler.f
|
${CMAKE_BINARY_DIR}${CMAKE_FILES_DIRECTORY}/CMakeTmp/testFortranCompiler.f
|
||||||
CMAKE_FLAGS "${CHECK_FUNCTION_EXISTS_ADD_LIBRARIES}"
|
${CHECK_FUNCTION_EXISTS_ADD_LIBRARIES}
|
||||||
OUTPUT_VARIABLE OUTPUT
|
OUTPUT_VARIABLE OUTPUT
|
||||||
)
|
)
|
||||||
# message(STATUS "${OUTPUT}")
|
# message(STATUS "${OUTPUT}")
|
||||||
|
|
|
@ -27,7 +27,6 @@
|
||||||
# (To distribute this file outside of CMake, substitute the full
|
# (To distribute this file outside of CMake, substitute the full
|
||||||
# License text for the above reference.)
|
# License text for the above reference.)
|
||||||
|
|
||||||
include("${CMAKE_CURRENT_LIST_DIR}/CMakeExpandImportedTargets.cmake")
|
|
||||||
|
|
||||||
|
|
||||||
macro(CHECK_FUNCTION_EXISTS FUNCTION VARIABLE)
|
macro(CHECK_FUNCTION_EXISTS FUNCTION VARIABLE)
|
||||||
|
@ -36,10 +35,8 @@ macro(CHECK_FUNCTION_EXISTS FUNCTION VARIABLE)
|
||||||
"-DCHECK_FUNCTION_EXISTS=${FUNCTION} ${CMAKE_REQUIRED_FLAGS}")
|
"-DCHECK_FUNCTION_EXISTS=${FUNCTION} ${CMAKE_REQUIRED_FLAGS}")
|
||||||
message(STATUS "Looking for ${FUNCTION}")
|
message(STATUS "Looking for ${FUNCTION}")
|
||||||
if(CMAKE_REQUIRED_LIBRARIES)
|
if(CMAKE_REQUIRED_LIBRARIES)
|
||||||
# this one translates potentially used imported library targets to their files on disk
|
|
||||||
CMAKE_EXPAND_IMPORTED_TARGETS(_ADJUSTED_CMAKE_REQUIRED_LIBRARIES LIBRARIES ${CMAKE_REQUIRED_LIBRARIES} CONFIGURATION "${CMAKE_TRY_COMPILE_CONFIGURATION}")
|
|
||||||
set(CHECK_FUNCTION_EXISTS_ADD_LIBRARIES
|
set(CHECK_FUNCTION_EXISTS_ADD_LIBRARIES
|
||||||
"-DLINK_LIBRARIES:STRING=${_ADJUSTED_CMAKE_REQUIRED_LIBRARIES}")
|
LINK_LIBRARIES ${CMAKE_REQUIRED_LIBRARIES})
|
||||||
else()
|
else()
|
||||||
set(CHECK_FUNCTION_EXISTS_ADD_LIBRARIES)
|
set(CHECK_FUNCTION_EXISTS_ADD_LIBRARIES)
|
||||||
endif()
|
endif()
|
||||||
|
@ -53,8 +50,8 @@ macro(CHECK_FUNCTION_EXISTS FUNCTION VARIABLE)
|
||||||
${CMAKE_BINARY_DIR}
|
${CMAKE_BINARY_DIR}
|
||||||
${CMAKE_ROOT}/Modules/CheckFunctionExists.c
|
${CMAKE_ROOT}/Modules/CheckFunctionExists.c
|
||||||
COMPILE_DEFINITIONS ${CMAKE_REQUIRED_DEFINITIONS}
|
COMPILE_DEFINITIONS ${CMAKE_REQUIRED_DEFINITIONS}
|
||||||
|
${CHECK_FUNCTION_EXISTS_ADD_LIBRARIES}
|
||||||
CMAKE_FLAGS -DCOMPILE_DEFINITIONS:STRING=${MACRO_CHECK_FUNCTION_DEFINITIONS}
|
CMAKE_FLAGS -DCOMPILE_DEFINITIONS:STRING=${MACRO_CHECK_FUNCTION_DEFINITIONS}
|
||||||
"${CHECK_FUNCTION_EXISTS_ADD_LIBRARIES}"
|
|
||||||
"${CHECK_FUNCTION_EXISTS_ADD_INCLUDES}"
|
"${CHECK_FUNCTION_EXISTS_ADD_INCLUDES}"
|
||||||
OUTPUT_VARIABLE OUTPUT)
|
OUTPUT_VARIABLE OUTPUT)
|
||||||
if(${VARIABLE})
|
if(${VARIABLE})
|
||||||
|
|
|
@ -26,7 +26,6 @@
|
||||||
# (To distribute this file outside of CMake, substitute the full
|
# (To distribute this file outside of CMake, substitute the full
|
||||||
# License text for the above reference.)
|
# License text for the above reference.)
|
||||||
|
|
||||||
include("${CMAKE_CURRENT_LIST_DIR}/CMakeExpandImportedTargets.cmake")
|
|
||||||
|
|
||||||
|
|
||||||
macro(CHECK_LIBRARY_EXISTS LIBRARY FUNCTION LOCATION VARIABLE)
|
macro(CHECK_LIBRARY_EXISTS LIBRARY FUNCTION LOCATION VARIABLE)
|
||||||
|
@ -36,19 +35,17 @@ macro(CHECK_LIBRARY_EXISTS LIBRARY FUNCTION LOCATION VARIABLE)
|
||||||
message(STATUS "Looking for ${FUNCTION} in ${LIBRARY}")
|
message(STATUS "Looking for ${FUNCTION} in ${LIBRARY}")
|
||||||
set(CHECK_LIBRARY_EXISTS_LIBRARIES ${LIBRARY})
|
set(CHECK_LIBRARY_EXISTS_LIBRARIES ${LIBRARY})
|
||||||
if(CMAKE_REQUIRED_LIBRARIES)
|
if(CMAKE_REQUIRED_LIBRARIES)
|
||||||
# this one translates potentially used imported library targets to their files on disk
|
|
||||||
CMAKE_EXPAND_IMPORTED_TARGETS(_ADJUSTED_CMAKE_REQUIRED_LIBRARIES LIBRARIES ${CMAKE_REQUIRED_LIBRARIES} CONFIGURATION "${CMAKE_TRY_COMPILE_CONFIGURATION}")
|
|
||||||
set(CHECK_LIBRARY_EXISTS_LIBRARIES
|
set(CHECK_LIBRARY_EXISTS_LIBRARIES
|
||||||
${CHECK_LIBRARY_EXISTS_LIBRARIES} ${_ADJUSTED_CMAKE_REQUIRED_LIBRARIES})
|
${CHECK_LIBRARY_EXISTS_LIBRARIES} ${CMAKE_REQUIRED_LIBRARIES})
|
||||||
endif()
|
endif()
|
||||||
try_compile(${VARIABLE}
|
try_compile(${VARIABLE}
|
||||||
${CMAKE_BINARY_DIR}
|
${CMAKE_BINARY_DIR}
|
||||||
${CMAKE_ROOT}/Modules/CheckFunctionExists.c
|
${CMAKE_ROOT}/Modules/CheckFunctionExists.c
|
||||||
COMPILE_DEFINITIONS ${CMAKE_REQUIRED_DEFINITIONS}
|
COMPILE_DEFINITIONS ${CMAKE_REQUIRED_DEFINITIONS}
|
||||||
|
LINK_LIBRARIES ${CHECK_LIBRARY_EXISTS_LIBRARIES}
|
||||||
CMAKE_FLAGS
|
CMAKE_FLAGS
|
||||||
-DCOMPILE_DEFINITIONS:STRING=${MACRO_CHECK_LIBRARY_EXISTS_DEFINITION}
|
-DCOMPILE_DEFINITIONS:STRING=${MACRO_CHECK_LIBRARY_EXISTS_DEFINITION}
|
||||||
-DLINK_DIRECTORIES:STRING=${LOCATION}
|
-DLINK_DIRECTORIES:STRING=${LOCATION}
|
||||||
"-DLINK_LIBRARIES:STRING=${CHECK_LIBRARY_EXISTS_LIBRARIES}"
|
|
||||||
OUTPUT_VARIABLE OUTPUT)
|
OUTPUT_VARIABLE OUTPUT)
|
||||||
|
|
||||||
if(${VARIABLE})
|
if(${VARIABLE})
|
||||||
|
|
|
@ -34,7 +34,6 @@
|
||||||
# License text for the above reference.)
|
# License text for the above reference.)
|
||||||
#
|
#
|
||||||
|
|
||||||
include("${CMAKE_CURRENT_LIST_DIR}/CMakeExpandImportedTargets.cmake")
|
|
||||||
|
|
||||||
get_filename_component(__check_proto_def_dir "${CMAKE_CURRENT_LIST_FILE}" PATH)
|
get_filename_component(__check_proto_def_dir "${CMAKE_CURRENT_LIST_FILE}" PATH)
|
||||||
|
|
||||||
|
@ -46,10 +45,8 @@ function(CHECK_PROTOTYPE_DEFINITION _FUNCTION _PROTOTYPE _RETURN _HEADER _VARIAB
|
||||||
|
|
||||||
set(CHECK_PROTOTYPE_DEFINITION_FLAGS ${CMAKE_REQUIRED_FLAGS})
|
set(CHECK_PROTOTYPE_DEFINITION_FLAGS ${CMAKE_REQUIRED_FLAGS})
|
||||||
if (CMAKE_REQUIRED_LIBRARIES)
|
if (CMAKE_REQUIRED_LIBRARIES)
|
||||||
# this one translates potentially used imported library targets to their files on disk
|
|
||||||
cmake_expand_imported_targets(_ADJUSTED_CMAKE_REQUIRED_LIBRARIES LIBRARIES ${CMAKE_REQUIRED_LIBRARIES} CONFIGURATION "${CMAKE_TRY_COMPILE_CONFIGURATION}")
|
|
||||||
set(CHECK_PROTOTYPE_DEFINITION_LIBS
|
set(CHECK_PROTOTYPE_DEFINITION_LIBS
|
||||||
"-DLINK_LIBRARIES:STRING=${_ADJUSTED_CMAKE_REQUIRED_LIBRARIES}")
|
LINK_LIBRARIES ${CMAKE_REQUIRED_LIBRARIES})
|
||||||
else()
|
else()
|
||||||
set(CHECK_PROTOTYPE_DEFINITION_LIBS)
|
set(CHECK_PROTOTYPE_DEFINITION_LIBS)
|
||||||
endif()
|
endif()
|
||||||
|
@ -78,8 +75,8 @@ function(CHECK_PROTOTYPE_DEFINITION _FUNCTION _PROTOTYPE _RETURN _HEADER _VARIAB
|
||||||
${CMAKE_BINARY_DIR}
|
${CMAKE_BINARY_DIR}
|
||||||
${CMAKE_BINARY_DIR}${CMAKE_FILES_DIRECTORY}/CMakeTmp/CheckPrototypeDefinition.c
|
${CMAKE_BINARY_DIR}${CMAKE_FILES_DIRECTORY}/CMakeTmp/CheckPrototypeDefinition.c
|
||||||
COMPILE_DEFINITIONS ${CMAKE_REQUIRED_DEFINITIONS}
|
COMPILE_DEFINITIONS ${CMAKE_REQUIRED_DEFINITIONS}
|
||||||
|
${CHECK_PROTOTYPE_DEFINITION_LIBS}
|
||||||
CMAKE_FLAGS -DCOMPILE_DEFINITIONS:STRING=${CHECK_PROTOTYPE_DEFINITION_FLAGS}
|
CMAKE_FLAGS -DCOMPILE_DEFINITIONS:STRING=${CHECK_PROTOTYPE_DEFINITION_FLAGS}
|
||||||
"${CHECK_PROTOTYPE_DEFINITION_LIBS}"
|
|
||||||
"${CMAKE_SYMBOL_EXISTS_INCLUDES}"
|
"${CMAKE_SYMBOL_EXISTS_INCLUDES}"
|
||||||
OUTPUT_VARIABLE OUTPUT)
|
OUTPUT_VARIABLE OUTPUT)
|
||||||
|
|
||||||
|
|
|
@ -35,7 +35,6 @@
|
||||||
# (To distribute this file outside of CMake, substitute the full
|
# (To distribute this file outside of CMake, substitute the full
|
||||||
# License text for the above reference.)
|
# License text for the above reference.)
|
||||||
|
|
||||||
include("${CMAKE_CURRENT_LIST_DIR}/CMakeExpandImportedTargets.cmake")
|
|
||||||
|
|
||||||
|
|
||||||
macro(CHECK_SYMBOL_EXISTS SYMBOL FILES VARIABLE)
|
macro(CHECK_SYMBOL_EXISTS SYMBOL FILES VARIABLE)
|
||||||
|
@ -47,10 +46,8 @@ macro(_CHECK_SYMBOL_EXISTS SOURCEFILE SYMBOL FILES VARIABLE)
|
||||||
set(CMAKE_CONFIGURABLE_FILE_CONTENT "/* */\n")
|
set(CMAKE_CONFIGURABLE_FILE_CONTENT "/* */\n")
|
||||||
set(MACRO_CHECK_SYMBOL_EXISTS_FLAGS ${CMAKE_REQUIRED_FLAGS})
|
set(MACRO_CHECK_SYMBOL_EXISTS_FLAGS ${CMAKE_REQUIRED_FLAGS})
|
||||||
if(CMAKE_REQUIRED_LIBRARIES)
|
if(CMAKE_REQUIRED_LIBRARIES)
|
||||||
# this one translates potentially used imported library targets to their files on disk
|
|
||||||
CMAKE_EXPAND_IMPORTED_TARGETS(_ADJUSTED_CMAKE_REQUIRED_LIBRARIES LIBRARIES ${CMAKE_REQUIRED_LIBRARIES} CONFIGURATION "${CMAKE_TRY_COMPILE_CONFIGURATION}")
|
|
||||||
set(CHECK_SYMBOL_EXISTS_LIBS
|
set(CHECK_SYMBOL_EXISTS_LIBS
|
||||||
"-DLINK_LIBRARIES:STRING=${_ADJUSTED_CMAKE_REQUIRED_LIBRARIES}")
|
LINK_LIBRARIES ${CMAKE_REQUIRED_LIBRARIES})
|
||||||
else()
|
else()
|
||||||
set(CHECK_SYMBOL_EXISTS_LIBS)
|
set(CHECK_SYMBOL_EXISTS_LIBS)
|
||||||
endif()
|
endif()
|
||||||
|
@ -75,9 +72,9 @@ macro(_CHECK_SYMBOL_EXISTS SOURCEFILE SYMBOL FILES VARIABLE)
|
||||||
${CMAKE_BINARY_DIR}
|
${CMAKE_BINARY_DIR}
|
||||||
"${SOURCEFILE}"
|
"${SOURCEFILE}"
|
||||||
COMPILE_DEFINITIONS ${CMAKE_REQUIRED_DEFINITIONS}
|
COMPILE_DEFINITIONS ${CMAKE_REQUIRED_DEFINITIONS}
|
||||||
|
${CHECK_SYMBOL_EXISTS_LIBS}
|
||||||
CMAKE_FLAGS
|
CMAKE_FLAGS
|
||||||
-DCOMPILE_DEFINITIONS:STRING=${MACRO_CHECK_SYMBOL_EXISTS_FLAGS}
|
-DCOMPILE_DEFINITIONS:STRING=${MACRO_CHECK_SYMBOL_EXISTS_FLAGS}
|
||||||
"${CHECK_SYMBOL_EXISTS_LIBS}"
|
|
||||||
"${CMAKE_SYMBOL_EXISTS_INCLUDES}"
|
"${CMAKE_SYMBOL_EXISTS_INCLUDES}"
|
||||||
OUTPUT_VARIABLE OUTPUT)
|
OUTPUT_VARIABLE OUTPUT)
|
||||||
if(${VARIABLE})
|
if(${VARIABLE})
|
||||||
|
|
|
@ -52,7 +52,6 @@
|
||||||
# License text for the above reference.)
|
# License text for the above reference.)
|
||||||
|
|
||||||
include(CheckIncludeFile)
|
include(CheckIncludeFile)
|
||||||
include("${CMAKE_CURRENT_LIST_DIR}/CMakeExpandImportedTargets.cmake")
|
|
||||||
|
|
||||||
cmake_policy(PUSH)
|
cmake_policy(PUSH)
|
||||||
cmake_minimum_required(VERSION 2.6 FATAL_ERROR)
|
cmake_minimum_required(VERSION 2.6 FATAL_ERROR)
|
||||||
|
@ -83,18 +82,16 @@ function(__check_type_size_impl type var map builtin)
|
||||||
|
|
||||||
# Perform the check.
|
# Perform the check.
|
||||||
|
|
||||||
# this one translates potentially used imported library targets to their files on disk
|
|
||||||
cmake_expand_imported_targets(_ADJUSTED_CMAKE_REQUIRED_LIBRARIES LIBRARIES ${CMAKE_REQUIRED_LIBRARIES} CONFIGURATION "${CMAKE_TRY_COMPILE_CONFIGURATION}")
|
|
||||||
|
|
||||||
set(src ${CMAKE_BINARY_DIR}${CMAKE_FILES_DIRECTORY}/CheckTypeSize/${var}.c)
|
set(src ${CMAKE_BINARY_DIR}${CMAKE_FILES_DIRECTORY}/CheckTypeSize/${var}.c)
|
||||||
set(bin ${CMAKE_BINARY_DIR}${CMAKE_FILES_DIRECTORY}/CheckTypeSize/${var}.bin)
|
set(bin ${CMAKE_BINARY_DIR}${CMAKE_FILES_DIRECTORY}/CheckTypeSize/${var}.bin)
|
||||||
configure_file(${__check_type_size_dir}/CheckTypeSize.c.in ${src} @ONLY)
|
configure_file(${__check_type_size_dir}/CheckTypeSize.c.in ${src} @ONLY)
|
||||||
try_compile(HAVE_${var} ${CMAKE_BINARY_DIR} ${src}
|
try_compile(HAVE_${var} ${CMAKE_BINARY_DIR} ${src}
|
||||||
COMPILE_DEFINITIONS ${CMAKE_REQUIRED_DEFINITIONS}
|
COMPILE_DEFINITIONS ${CMAKE_REQUIRED_DEFINITIONS}
|
||||||
|
LINK_LIBRARIES ${CMAKE_REQUIRED_LIBRARIES}
|
||||||
CMAKE_FLAGS
|
CMAKE_FLAGS
|
||||||
"-DCOMPILE_DEFINITIONS:STRING=${CMAKE_REQUIRED_FLAGS}"
|
"-DCOMPILE_DEFINITIONS:STRING=${CMAKE_REQUIRED_FLAGS}"
|
||||||
"-DINCLUDE_DIRECTORIES:STRING=${CMAKE_REQUIRED_INCLUDES}"
|
"-DINCLUDE_DIRECTORIES:STRING=${CMAKE_REQUIRED_INCLUDES}"
|
||||||
"-DLINK_LIBRARIES:STRING=${_ADJUSTED_CMAKE_REQUIRED_LIBRARIES}"
|
|
||||||
OUTPUT_VARIABLE output
|
OUTPUT_VARIABLE output
|
||||||
COPY_FILE ${bin}
|
COPY_FILE ${bin}
|
||||||
)
|
)
|
||||||
|
|
|
@ -26,7 +26,6 @@
|
||||||
# (To distribute this file outside of CMake, substitute the full
|
# (To distribute this file outside of CMake, substitute the full
|
||||||
# License text for the above reference.)
|
# License text for the above reference.)
|
||||||
|
|
||||||
include("${CMAKE_CURRENT_LIST_DIR}/CMakeExpandImportedTargets.cmake")
|
|
||||||
|
|
||||||
|
|
||||||
macro(CHECK_VARIABLE_EXISTS VAR VARIABLE)
|
macro(CHECK_VARIABLE_EXISTS VAR VARIABLE)
|
||||||
|
@ -35,10 +34,8 @@ macro(CHECK_VARIABLE_EXISTS VAR VARIABLE)
|
||||||
"-DCHECK_VARIABLE_EXISTS=${VAR} ${CMAKE_REQUIRED_FLAGS}")
|
"-DCHECK_VARIABLE_EXISTS=${VAR} ${CMAKE_REQUIRED_FLAGS}")
|
||||||
message(STATUS "Looking for ${VAR}")
|
message(STATUS "Looking for ${VAR}")
|
||||||
if(CMAKE_REQUIRED_LIBRARIES)
|
if(CMAKE_REQUIRED_LIBRARIES)
|
||||||
# this one translates potentially used imported library targets to their files on disk
|
|
||||||
CMAKE_EXPAND_IMPORTED_TARGETS(_ADJUSTED_CMAKE_REQUIRED_LIBRARIES LIBRARIES ${CMAKE_REQUIRED_LIBRARIES} CONFIGURATION "${CMAKE_TRY_COMPILE_CONFIGURATION}")
|
|
||||||
set(CHECK_VARIABLE_EXISTS_ADD_LIBRARIES
|
set(CHECK_VARIABLE_EXISTS_ADD_LIBRARIES
|
||||||
"-DLINK_LIBRARIES:STRING=${_ADJUSTED_CMAKE_REQUIRED_LIBRARIES}")
|
LINK_LIBRARIES ${CMAKE_REQUIRED_LIBRARIES})
|
||||||
else()
|
else()
|
||||||
set(CHECK_VARIABLE_EXISTS_ADD_LIBRARIES)
|
set(CHECK_VARIABLE_EXISTS_ADD_LIBRARIES)
|
||||||
endif()
|
endif()
|
||||||
|
@ -46,8 +43,8 @@ macro(CHECK_VARIABLE_EXISTS VAR VARIABLE)
|
||||||
${CMAKE_BINARY_DIR}
|
${CMAKE_BINARY_DIR}
|
||||||
${CMAKE_ROOT}/Modules/CheckVariableExists.c
|
${CMAKE_ROOT}/Modules/CheckVariableExists.c
|
||||||
COMPILE_DEFINITIONS ${CMAKE_REQUIRED_DEFINITIONS}
|
COMPILE_DEFINITIONS ${CMAKE_REQUIRED_DEFINITIONS}
|
||||||
|
${CHECK_VARIABLE_EXISTS_ADD_LIBRARIES}
|
||||||
CMAKE_FLAGS -DCOMPILE_DEFINITIONS:STRING=${MACRO_CHECK_VARIABLE_DEFINITIONS}
|
CMAKE_FLAGS -DCOMPILE_DEFINITIONS:STRING=${MACRO_CHECK_VARIABLE_DEFINITIONS}
|
||||||
"${CHECK_VARIABLE_EXISTS_ADD_LIBRARIES}"
|
|
||||||
OUTPUT_VARIABLE OUTPUT)
|
OUTPUT_VARIABLE OUTPUT)
|
||||||
if(${VARIABLE})
|
if(${VARIABLE})
|
||||||
set(${VARIABLE} 1 CACHE INTERNAL "Have variable ${VAR}")
|
set(${VARIABLE} 1 CACHE INTERNAL "Have variable ${VAR}")
|
||||||
|
|
|
@ -176,6 +176,8 @@ set(SRCS
|
||||||
cmExportFileGenerator.cxx
|
cmExportFileGenerator.cxx
|
||||||
cmExportInstallFileGenerator.h
|
cmExportInstallFileGenerator.h
|
||||||
cmExportInstallFileGenerator.cxx
|
cmExportInstallFileGenerator.cxx
|
||||||
|
cmExportTryCompileFileGenerator.h
|
||||||
|
cmExportTryCompileFileGenerator.cxx
|
||||||
cmExportSet.h
|
cmExportSet.h
|
||||||
cmExportSet.cxx
|
cmExportSet.cxx
|
||||||
cmExportSetMap.h
|
cmExportSetMap.h
|
||||||
|
|
|
@ -13,8 +13,11 @@
|
||||||
#include "cmake.h"
|
#include "cmake.h"
|
||||||
#include "cmCacheManager.h"
|
#include "cmCacheManager.h"
|
||||||
#include "cmGlobalGenerator.h"
|
#include "cmGlobalGenerator.h"
|
||||||
|
#include "cmExportTryCompileFileGenerator.h"
|
||||||
#include <cmsys/Directory.hxx>
|
#include <cmsys/Directory.hxx>
|
||||||
|
|
||||||
|
#include <assert.h>
|
||||||
|
|
||||||
int cmCoreTryCompile::TryCompileCode(std::vector<std::string> const& argv)
|
int cmCoreTryCompile::TryCompileCode(std::vector<std::string> const& argv)
|
||||||
{
|
{
|
||||||
this->BinaryDirectory = argv[1].c_str();
|
this->BinaryDirectory = argv[1].c_str();
|
||||||
|
@ -39,7 +42,8 @@ int cmCoreTryCompile::TryCompileCode(std::vector<std::string> const& argv)
|
||||||
// is not used, so it matches regular command line parsing which has
|
// is not used, so it matches regular command line parsing which has
|
||||||
// the program name as arg 0
|
// the program name as arg 0
|
||||||
for (; i < argv.size() && argv[i] != "COMPILE_DEFINITIONS" &&
|
for (; i < argv.size() && argv[i] != "COMPILE_DEFINITIONS" &&
|
||||||
argv[i] != "OUTPUT_VARIABLE";
|
argv[i] != "OUTPUT_VARIABLE" &&
|
||||||
|
argv[i] != "LINK_LIBRARIES";
|
||||||
++i)
|
++i)
|
||||||
{
|
{
|
||||||
extraArgs++;
|
extraArgs++;
|
||||||
|
@ -75,7 +79,8 @@ int cmCoreTryCompile::TryCompileCode(std::vector<std::string> const& argv)
|
||||||
{
|
{
|
||||||
extraArgs++;
|
extraArgs++;
|
||||||
for (i = i + 1; i < argv.size() && argv[i] != "CMAKE_FLAGS" &&
|
for (i = i + 1; i < argv.size() && argv[i] != "CMAKE_FLAGS" &&
|
||||||
argv[i] != "OUTPUT_VARIABLE";
|
argv[i] != "OUTPUT_VARIABLE" &&
|
||||||
|
argv[i] != "LINK_LIBRARIES";
|
||||||
++i)
|
++i)
|
||||||
{
|
{
|
||||||
extraArgs++;
|
extraArgs++;
|
||||||
|
@ -85,6 +90,61 @@ int cmCoreTryCompile::TryCompileCode(std::vector<std::string> const& argv)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
std::vector<cmTarget*> targets;
|
||||||
|
std::string libsToLink = " ";
|
||||||
|
bool useOldLinkLibs = true;
|
||||||
|
for (i = 3; i < argv.size(); ++i)
|
||||||
|
{
|
||||||
|
if (argv[i] == "LINK_LIBRARIES")
|
||||||
|
{
|
||||||
|
if ( argv.size() <= (i+1) )
|
||||||
|
{
|
||||||
|
this->Makefile->IssueMessage(cmake::FATAL_ERROR,
|
||||||
|
"LINK_LIBRARIES specified but there is no content");
|
||||||
|
return -1;
|
||||||
|
}
|
||||||
|
extraArgs++;
|
||||||
|
++i;
|
||||||
|
useOldLinkLibs = false;
|
||||||
|
for ( ; i < argv.size() && argv[i] != "CMAKE_FLAGS"
|
||||||
|
&& argv[i] != "COMPILE_DEFINITIONS" && argv[i] != "OUTPUT_VARIABLE";
|
||||||
|
++i)
|
||||||
|
{
|
||||||
|
extraArgs++;
|
||||||
|
libsToLink += argv[i] + " ";
|
||||||
|
cmTarget *tgt = this->Makefile->FindTargetToUse(argv[i].c_str());
|
||||||
|
if (!tgt)
|
||||||
|
{
|
||||||
|
continue;
|
||||||
|
}
|
||||||
|
switch(tgt->GetType())
|
||||||
|
{
|
||||||
|
case cmTarget::SHARED_LIBRARY:
|
||||||
|
case cmTarget::STATIC_LIBRARY:
|
||||||
|
case cmTarget::UNKNOWN_LIBRARY:
|
||||||
|
break;
|
||||||
|
case cmTarget::EXECUTABLE:
|
||||||
|
if (tgt->IsExecutableWithExports())
|
||||||
|
{
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
default:
|
||||||
|
this->Makefile->IssueMessage(cmake::FATAL_ERROR,
|
||||||
|
"Only libraries may be used as try_compile IMPORTED "
|
||||||
|
"LINK_LIBRARIES. Got " + std::string(tgt->GetName()) + " of "
|
||||||
|
"type " + tgt->GetTargetTypeName(tgt->GetType()) + ".");
|
||||||
|
return -1;
|
||||||
|
}
|
||||||
|
if (!tgt->IsImported())
|
||||||
|
{
|
||||||
|
continue;
|
||||||
|
}
|
||||||
|
targets.push_back(tgt);
|
||||||
|
}
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
// look for COPY_FILE
|
// look for COPY_FILE
|
||||||
std::string copyFile;
|
std::string copyFile;
|
||||||
for (i = 3; i < argv.size(); ++i)
|
for (i = 3; i < argv.size(); ++i)
|
||||||
|
@ -247,6 +307,32 @@ int cmCoreTryCompile::TryCompileCode(std::vector<std::string> const& argv)
|
||||||
fprintf(fout, ")\n");
|
fprintf(fout, ")\n");
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/* Use a random file name to avoid rapid creation and deletion
|
||||||
|
of the same executable name (some filesystems fail on that). */
|
||||||
|
sprintf(targetNameBuf, "cmTryCompileExec%u",
|
||||||
|
cmSystemTools::RandomSeed());
|
||||||
|
targetName = targetNameBuf;
|
||||||
|
|
||||||
|
if (!targets.empty())
|
||||||
|
{
|
||||||
|
std::string fname = "/" + std::string(targetName) + "Targets.cmake";
|
||||||
|
cmExportTryCompileFileGenerator tcfg;
|
||||||
|
tcfg.SetExportFile((this->BinaryDirectory + fname).c_str());
|
||||||
|
tcfg.SetExports(targets);
|
||||||
|
tcfg.SetConfig(this->Makefile->GetDefinition(
|
||||||
|
"CMAKE_TRY_COMPILE_CONFIGURATION"));
|
||||||
|
|
||||||
|
if(!tcfg.GenerateImportFile())
|
||||||
|
{
|
||||||
|
this->Makefile->IssueMessage(cmake::FATAL_ERROR,
|
||||||
|
"could not write export file.");
|
||||||
|
return -1;
|
||||||
|
}
|
||||||
|
fprintf(fout,
|
||||||
|
"\ninclude(\"${CMAKE_CURRENT_LIST_DIR}/%s\")\n\n",
|
||||||
|
fname.c_str());
|
||||||
|
}
|
||||||
|
|
||||||
/* for the TRY_COMPILEs we want to be able to specify the architecture.
|
/* for the TRY_COMPILEs we want to be able to specify the architecture.
|
||||||
So the user can set CMAKE_OSX_ARCHITECTURE to i386;ppc and then set
|
So the user can set CMAKE_OSX_ARCHITECTURE to i386;ppc and then set
|
||||||
CMAKE_TRY_COMPILE_OSX_ARCHITECTURE first to i386 and then to ppc to
|
CMAKE_TRY_COMPILE_OSX_ARCHITECTURE first to i386 and then to ppc to
|
||||||
|
@ -286,18 +372,22 @@ int cmCoreTryCompile::TryCompileCode(std::vector<std::string> const& argv)
|
||||||
fprintf(fout, "SET(CMAKE_POSITION_INDEPENDENT_CODE \"ON\")\n");
|
fprintf(fout, "SET(CMAKE_POSITION_INDEPENDENT_CODE \"ON\")\n");
|
||||||
}
|
}
|
||||||
|
|
||||||
/* Use a random file name to avoid rapid creation and deletion
|
|
||||||
of the same executable name (some filesystems fail on that). */
|
|
||||||
sprintf(targetNameBuf, "cmTryCompileExec%u",
|
|
||||||
cmSystemTools::RandomSeed());
|
|
||||||
targetName = targetNameBuf;
|
|
||||||
|
|
||||||
/* Put the executable at a known location (for COPY_FILE). */
|
/* Put the executable at a known location (for COPY_FILE). */
|
||||||
fprintf(fout, "SET(CMAKE_RUNTIME_OUTPUT_DIRECTORY \"%s\")\n",
|
fprintf(fout, "SET(CMAKE_RUNTIME_OUTPUT_DIRECTORY \"%s\")\n",
|
||||||
this->BinaryDirectory.c_str());
|
this->BinaryDirectory.c_str());
|
||||||
/* Create the actual executable. */
|
/* Create the actual executable. */
|
||||||
fprintf(fout, "ADD_EXECUTABLE(%s \"%s\")\n", targetName, source.c_str());
|
fprintf(fout, "ADD_EXECUTABLE(%s \"%s\")\n", targetName, source.c_str());
|
||||||
fprintf(fout, "TARGET_LINK_LIBRARIES(%s ${LINK_LIBRARIES})\n",targetName);
|
if (useOldLinkLibs)
|
||||||
|
{
|
||||||
|
fprintf(fout,
|
||||||
|
"TARGET_LINK_LIBRARIES(%s ${LINK_LIBRARIES})\n",targetName);
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
fprintf(fout, "TARGET_LINK_LIBRARIES(%s %s)\n",
|
||||||
|
targetName,
|
||||||
|
libsToLink.c_str());
|
||||||
|
}
|
||||||
fclose(fout);
|
fclose(fout);
|
||||||
projectName = "CMAKE_TRY_COMPILE";
|
projectName = "CMAKE_TRY_COMPILE";
|
||||||
// if the source is not in CMakeTmp
|
// if the source is not in CMakeTmp
|
||||||
|
|
|
@ -679,6 +679,9 @@ cmExportFileGenerator
|
||||||
case cmTarget::MODULE_LIBRARY:
|
case cmTarget::MODULE_LIBRARY:
|
||||||
os << "add_library(" << targetName << " MODULE IMPORTED)\n";
|
os << "add_library(" << targetName << " MODULE IMPORTED)\n";
|
||||||
break;
|
break;
|
||||||
|
case cmTarget::UNKNOWN_LIBRARY:
|
||||||
|
os << "add_library(" << targetName << " UNKNOWN IMPORTED)\n";
|
||||||
|
break;
|
||||||
default: // should never happen
|
default: // should never happen
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
|
|
|
@ -0,0 +1,114 @@
|
||||||
|
/*============================================================================
|
||||||
|
CMake - Cross Platform Makefile Generator
|
||||||
|
Copyright 2013 Stephen Kelly <steveire@gmail.com>
|
||||||
|
|
||||||
|
Distributed under the OSI-approved BSD License (the "License");
|
||||||
|
see accompanying file Copyright.txt for details.
|
||||||
|
|
||||||
|
This software is distributed WITHOUT ANY WARRANTY; without even the
|
||||||
|
implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.
|
||||||
|
See the License for more information.
|
||||||
|
============================================================================*/
|
||||||
|
|
||||||
|
#include "cmExportTryCompileFileGenerator.h"
|
||||||
|
|
||||||
|
#include "cmGeneratedFileStream.h"
|
||||||
|
#include "cmGeneratorExpressionDAGChecker.h"
|
||||||
|
|
||||||
|
//----------------------------------------------------------------------------
|
||||||
|
bool cmExportTryCompileFileGenerator::GenerateMainFile(std::ostream& os)
|
||||||
|
{
|
||||||
|
std::set<cmTarget*> emitted;
|
||||||
|
std::set<cmTarget*> emittedDeps;
|
||||||
|
while(!this->Exports.empty())
|
||||||
|
{
|
||||||
|
cmTarget* te = this->Exports.back();
|
||||||
|
this->Exports.pop_back();
|
||||||
|
if (emitted.insert(te).second)
|
||||||
|
{
|
||||||
|
emittedDeps.insert(te);
|
||||||
|
this->GenerateImportTargetCode(os, te);
|
||||||
|
|
||||||
|
ImportPropertyMap properties;
|
||||||
|
|
||||||
|
this->FindTargets("INTERFACE_INCLUDE_DIRECTORIES", te, emittedDeps);
|
||||||
|
this->FindTargets("INTERFACE_COMPILE_DEFINITIONS", te, emittedDeps);
|
||||||
|
|
||||||
|
this->PopulateProperties(te, properties, emittedDeps);
|
||||||
|
|
||||||
|
this->GenerateInterfaceProperties(te, os, properties);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
|
||||||
|
std::string cmExportTryCompileFileGenerator::FindTargets(const char *propName,
|
||||||
|
cmTarget *tgt,
|
||||||
|
std::set<cmTarget*> &emitted)
|
||||||
|
{
|
||||||
|
const char *prop = tgt->GetProperty(propName);
|
||||||
|
if(!prop)
|
||||||
|
{
|
||||||
|
return std::string();
|
||||||
|
}
|
||||||
|
|
||||||
|
cmListFileBacktrace lfbt;
|
||||||
|
cmGeneratorExpression ge(lfbt);
|
||||||
|
|
||||||
|
cmGeneratorExpressionDAGChecker dagChecker(lfbt,
|
||||||
|
tgt->GetName(),
|
||||||
|
propName, 0, 0);
|
||||||
|
|
||||||
|
cmsys::auto_ptr<cmCompiledGeneratorExpression> cge = ge.Parse(prop);
|
||||||
|
|
||||||
|
cmTarget dummyHead;
|
||||||
|
dummyHead.SetType(cmTarget::EXECUTABLE, "try_compile_dummy_exe");
|
||||||
|
dummyHead.SetMakefile(tgt->GetMakefile());
|
||||||
|
|
||||||
|
std::string result = cge->Evaluate(tgt->GetMakefile(), this->Config,
|
||||||
|
false, &dummyHead, tgt, &dagChecker);
|
||||||
|
|
||||||
|
const std::set<cmTarget*> &allTargets = cge->GetAllTargetsSeen();
|
||||||
|
for(std::set<cmTarget*>::const_iterator li = allTargets.begin();
|
||||||
|
li != allTargets.end(); ++li)
|
||||||
|
{
|
||||||
|
if(emitted.insert(*li).second)
|
||||||
|
{
|
||||||
|
this->Exports.push_back(*li);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
return result;
|
||||||
|
}
|
||||||
|
|
||||||
|
//----------------------------------------------------------------------------
|
||||||
|
void
|
||||||
|
cmExportTryCompileFileGenerator::PopulateProperties(cmTarget* target,
|
||||||
|
ImportPropertyMap& properties,
|
||||||
|
std::set<cmTarget*> &emitted)
|
||||||
|
{
|
||||||
|
cmPropertyMap props = target->GetProperties();
|
||||||
|
for(cmPropertyMap::const_iterator i = props.begin(); i != props.end(); ++i)
|
||||||
|
{
|
||||||
|
properties[i->first] = i->second.GetValue();
|
||||||
|
|
||||||
|
if(i->first.find("IMPORTED_LINK_INTERFACE_LIBRARIES") == 0)
|
||||||
|
{
|
||||||
|
const std::string libs = i->second.GetValue();
|
||||||
|
|
||||||
|
std::string evalResult = this->FindTargets(i->first.c_str(),
|
||||||
|
target, emitted);
|
||||||
|
|
||||||
|
std::vector<std::string> depends;
|
||||||
|
cmSystemTools::ExpandListArgument(evalResult, depends);
|
||||||
|
for(std::vector<std::string>::const_iterator li = depends.begin();
|
||||||
|
li != depends.end(); ++li)
|
||||||
|
{
|
||||||
|
cmTarget *tgt = target->GetMakefile()->FindTargetToUse(li->c_str());
|
||||||
|
if(tgt && emitted.insert(tgt).second)
|
||||||
|
{
|
||||||
|
this->Exports.push_back(tgt);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
|
@ -0,0 +1,55 @@
|
||||||
|
/*============================================================================
|
||||||
|
CMake - Cross Platform Makefile Generator
|
||||||
|
Copyright 2013 Stephen Kelly <steveire@gmail.com>
|
||||||
|
|
||||||
|
Distributed under the OSI-approved BSD License (the "License");
|
||||||
|
see accompanying file Copyright.txt for details.
|
||||||
|
|
||||||
|
This software is distributed WITHOUT ANY WARRANTY; without even the
|
||||||
|
implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.
|
||||||
|
See the License for more information.
|
||||||
|
============================================================================*/
|
||||||
|
#ifndef cmExportInstallFileGenerator_h
|
||||||
|
#define cmExportInstallFileGenerator_h
|
||||||
|
|
||||||
|
#include "cmExportFileGenerator.h"
|
||||||
|
|
||||||
|
class cmInstallExportGenerator;
|
||||||
|
class cmInstallTargetGenerator;
|
||||||
|
|
||||||
|
class cmExportTryCompileFileGenerator: public cmExportFileGenerator
|
||||||
|
{
|
||||||
|
public:
|
||||||
|
/** Set the list of targets to export. */
|
||||||
|
void SetExports(const std::vector<cmTarget*> &exports)
|
||||||
|
{ this->Exports = exports; }
|
||||||
|
void SetConfig(const char *config) { this->Config = config; }
|
||||||
|
protected:
|
||||||
|
|
||||||
|
// Implement virtual methods from the superclass.
|
||||||
|
virtual bool GenerateMainFile(std::ostream& os);
|
||||||
|
|
||||||
|
virtual void GenerateImportTargetsConfig(std::ostream&,
|
||||||
|
const char*,
|
||||||
|
std::string const&,
|
||||||
|
std::vector<std::string>&) {}
|
||||||
|
virtual void HandleMissingTarget(std::string&,
|
||||||
|
std::vector<std::string>&,
|
||||||
|
cmMakefile*,
|
||||||
|
cmTarget*,
|
||||||
|
cmTarget*) {}
|
||||||
|
|
||||||
|
void PopulateProperties(cmTarget* target,
|
||||||
|
ImportPropertyMap& properties,
|
||||||
|
std::set<cmTarget*> &emitted);
|
||||||
|
|
||||||
|
private:
|
||||||
|
std::string FindTargets(const char *prop, cmTarget *tgt,
|
||||||
|
std::set<cmTarget*> &emitted);
|
||||||
|
|
||||||
|
|
||||||
|
std::vector<cmTarget*> Exports;
|
||||||
|
const char *Config;
|
||||||
|
};
|
||||||
|
|
||||||
|
#endif
|
|
@ -114,7 +114,8 @@ const char *cmCompiledGeneratorExpression::Evaluate(
|
||||||
this->HadContextSensitiveCondition = context.HadContextSensitiveCondition;
|
this->HadContextSensitiveCondition = context.HadContextSensitiveCondition;
|
||||||
}
|
}
|
||||||
|
|
||||||
this->Targets = context.Targets;
|
this->DependTargets = context.DependTargets;
|
||||||
|
this->AllTargetsSeen = context.AllTargets;
|
||||||
// TODO: Return a std::string from here instead?
|
// TODO: Return a std::string from here instead?
|
||||||
return this->Output.c_str();
|
return this->Output.c_str();
|
||||||
}
|
}
|
||||||
|
|
|
@ -88,11 +88,14 @@ public:
|
||||||
|
|
||||||
/** Get set of targets found during evaluations. */
|
/** Get set of targets found during evaluations. */
|
||||||
std::set<cmTarget*> const& GetTargets() const
|
std::set<cmTarget*> const& GetTargets() const
|
||||||
{ return this->Targets; }
|
{ return this->DependTargets; }
|
||||||
|
|
||||||
std::set<cmStdString> const& GetSeenTargetProperties() const
|
std::set<cmStdString> const& GetSeenTargetProperties() const
|
||||||
{ return this->SeenTargetProperties; }
|
{ return this->SeenTargetProperties; }
|
||||||
|
|
||||||
|
std::set<cmTarget*> const& GetAllTargetsSeen() const
|
||||||
|
{ return this->AllTargetsSeen; }
|
||||||
|
|
||||||
~cmCompiledGeneratorExpression();
|
~cmCompiledGeneratorExpression();
|
||||||
|
|
||||||
std::string GetInput() const
|
std::string GetInput() const
|
||||||
|
@ -123,7 +126,8 @@ private:
|
||||||
const std::string Input;
|
const std::string Input;
|
||||||
bool NeedsParsing;
|
bool NeedsParsing;
|
||||||
|
|
||||||
mutable std::set<cmTarget*> Targets;
|
mutable std::set<cmTarget*> DependTargets;
|
||||||
|
mutable std::set<cmTarget*> AllTargetsSeen;
|
||||||
mutable std::set<cmStdString> SeenTargetProperties;
|
mutable std::set<cmStdString> SeenTargetProperties;
|
||||||
mutable std::string Output;
|
mutable std::string Output;
|
||||||
mutable bool HadContextSensitiveCondition;
|
mutable bool HadContextSensitiveCondition;
|
||||||
|
|
|
@ -392,6 +392,7 @@ static const struct TargetPropertyNode : public cmGeneratorExpressionNode
|
||||||
reportError(context, content->GetOriginalExpression(), e.str());
|
reportError(context, content->GetOriginalExpression(), e.str());
|
||||||
return std::string();
|
return std::string();
|
||||||
}
|
}
|
||||||
|
context->AllTargets.insert(target);
|
||||||
}
|
}
|
||||||
|
|
||||||
if (target == context->HeadTarget)
|
if (target == context->HeadTarget)
|
||||||
|
@ -852,7 +853,8 @@ struct TargetFilesystemArtifact : public cmGeneratorExpressionNode
|
||||||
"Target \"" + name + "\" is not an executable or library.");
|
"Target \"" + name + "\" is not an executable or library.");
|
||||||
return std::string();
|
return std::string();
|
||||||
}
|
}
|
||||||
context->Targets.insert(target);
|
context->DependTargets.insert(target);
|
||||||
|
context->AllTargets.insert(target);
|
||||||
|
|
||||||
std::string result =
|
std::string result =
|
||||||
TargetFilesystemArtifactResultCreator<linker, soname>::Create(
|
TargetFilesystemArtifactResultCreator<linker, soname>::Create(
|
||||||
|
|
|
@ -23,7 +23,8 @@ class cmTarget;
|
||||||
struct cmGeneratorExpressionContext
|
struct cmGeneratorExpressionContext
|
||||||
{
|
{
|
||||||
cmListFileBacktrace Backtrace;
|
cmListFileBacktrace Backtrace;
|
||||||
std::set<cmTarget*> Targets;
|
std::set<cmTarget*> DependTargets;
|
||||||
|
std::set<cmTarget*> AllTargets;
|
||||||
std::set<cmStdString> SeenTargetProperties;
|
std::set<cmStdString> SeenTargetProperties;
|
||||||
cmMakefile *Makefile;
|
cmMakefile *Makefile;
|
||||||
const char *Config;
|
const char *Config;
|
||||||
|
|
|
@ -67,6 +67,7 @@ public:
|
||||||
" try_compile(RESULT_VAR <bindir> <srcfile>\n"
|
" try_compile(RESULT_VAR <bindir> <srcfile>\n"
|
||||||
" [CMAKE_FLAGS flags...]\n"
|
" [CMAKE_FLAGS flags...]\n"
|
||||||
" [COMPILE_DEFINITIONS flags...]\n"
|
" [COMPILE_DEFINITIONS flags...]\n"
|
||||||
|
" [LINK_LIBRARIES libs...]\n"
|
||||||
" [OUTPUT_VARIABLE <var>]\n"
|
" [OUTPUT_VARIABLE <var>]\n"
|
||||||
" [COPY_FILE <fileName>])\n"
|
" [COPY_FILE <fileName>])\n"
|
||||||
"Try building a source file into an executable. "
|
"Try building a source file into an executable. "
|
||||||
|
@ -90,7 +91,12 @@ public:
|
||||||
"Some extra flags that can be included are, "
|
"Some extra flags that can be included are, "
|
||||||
"INCLUDE_DIRECTORIES, LINK_DIRECTORIES, and LINK_LIBRARIES. "
|
"INCLUDE_DIRECTORIES, LINK_DIRECTORIES, and LINK_LIBRARIES. "
|
||||||
"COMPILE_DEFINITIONS are -Ddefinition that will be passed to the "
|
"COMPILE_DEFINITIONS are -Ddefinition that will be passed to the "
|
||||||
"compile line. "
|
"compile line.\n"
|
||||||
|
"The srcfile signature also accepts a LINK_LIBRARIES argument which "
|
||||||
|
"may contain a list of libraries or IMPORTED targets which will be "
|
||||||
|
"linked to in the generated project. If LINK_LIBRARIES is specified "
|
||||||
|
"as a parameter to try_compile, then any LINK_LIBRARIES passed as "
|
||||||
|
"CMAKE_FLAGS will be ignored.\n"
|
||||||
"try_compile creates a CMakeList.txt "
|
"try_compile creates a CMakeList.txt "
|
||||||
"file on the fly that looks like this:\n"
|
"file on the fly that looks like this:\n"
|
||||||
" add_definitions( <expanded COMPILE_DEFINITIONS from calling "
|
" add_definitions( <expanded COMPILE_DEFINITIONS from calling "
|
||||||
|
|
|
@ -17,3 +17,5 @@ add_executable(imp_testTransExe1 imp_testTransExe1.c)
|
||||||
target_link_libraries(imp_testTransExe1 imp_lib1)
|
target_link_libraries(imp_testTransExe1 imp_lib1)
|
||||||
add_executable(imp_testTransExe1b imp_testTransExe1.c)
|
add_executable(imp_testTransExe1b imp_testTransExe1.c)
|
||||||
target_link_libraries(imp_testTransExe1b imp_lib1b)
|
target_link_libraries(imp_testTransExe1b imp_lib1b)
|
||||||
|
|
||||||
|
add_subdirectory(try_compile)
|
||||||
|
|
|
@ -0,0 +1,21 @@
|
||||||
|
|
||||||
|
cmake_minimum_required(VERSION 2.8)
|
||||||
|
|
||||||
|
find_package(testLibRequired 2.5 REQUIRED)
|
||||||
|
|
||||||
|
include(CheckCXXSourceCompiles)
|
||||||
|
|
||||||
|
set(CMAKE_REQUIRED_LIBRARIES Req::testSharedLibRequired)
|
||||||
|
check_cxx_source_compiles(
|
||||||
|
"
|
||||||
|
#include \"testSharedLibRequired.h\"
|
||||||
|
int main(int argc, char **argv)
|
||||||
|
{
|
||||||
|
TestSharedLibRequired req;
|
||||||
|
return req.foo();
|
||||||
|
}
|
||||||
|
" SHARED_LIB_REQUIRED)
|
||||||
|
|
||||||
|
if(NOT SHARED_LIB_REQUIRED)
|
||||||
|
message(SEND_ERROR "try_compile with IMPORTED targets failed!\n\n${OUTPUT}")
|
||||||
|
endif()
|
|
@ -214,6 +214,7 @@ CMAKE_CXX_SOURCES="\
|
||||||
cmMakefile \
|
cmMakefile \
|
||||||
cmExportFileGenerator \
|
cmExportFileGenerator \
|
||||||
cmExportInstallFileGenerator \
|
cmExportInstallFileGenerator \
|
||||||
|
cmExportTryCompileFileGenerator \
|
||||||
cmExportSet \
|
cmExportSet \
|
||||||
cmExportSetMap \
|
cmExportSetMap \
|
||||||
cmInstallDirectoryGenerator \
|
cmInstallDirectoryGenerator \
|
||||||
|
|
Loading…
Reference in New Issue