2009-04-06 19:11:33 +04:00
|
|
|
# Import targets from the exported build tree.
|
|
|
|
include(${Import_BINARY_DIR}/../Export/ExportBuildTree.cmake)
|
|
|
|
|
|
|
|
# Import targets from the exported install tree.
|
|
|
|
include(${CMAKE_INSTALL_PREFIX}/lib/exp/exp.cmake)
|
|
|
|
|
2012-09-23 21:19:55 +04:00
|
|
|
# Import two exports, where the Depends one depends on an exported target from the Required one:
|
2013-01-30 11:24:59 +04:00
|
|
|
include(${CMAKE_INSTALL_PREFIX}/lib/cmake/testLibRequired/testLibRequiredTargets.cmake)
|
|
|
|
include(${CMAKE_INSTALL_PREFIX}/lib/cmake/testLibDepends/testLibDependsTargets.cmake)
|
2012-09-23 21:19:55 +04:00
|
|
|
|
2009-04-06 19:11:33 +04:00
|
|
|
# Try referencing an executable imported from the install tree.
|
|
|
|
add_custom_command(
|
|
|
|
OUTPUT ${Import_BINARY_DIR}/exp_generated.c
|
|
|
|
COMMAND exp_testExe1 ${Import_BINARY_DIR}/exp_generated.c
|
|
|
|
DEPENDS exp_testExe1
|
|
|
|
)
|
|
|
|
add_custom_command(
|
|
|
|
OUTPUT ${Import_BINARY_DIR}/exp_generated3.c
|
|
|
|
COMMAND exp_testExe3 ${Import_BINARY_DIR}/exp_generated3.c
|
|
|
|
DEPENDS exp_testExe3
|
|
|
|
)
|
2015-08-11 22:19:03 +03:00
|
|
|
add_custom_command(
|
|
|
|
OUTPUT ${Import_BINARY_DIR}/exp_generated4.c
|
|
|
|
COMMAND exp_testExe4 ${Import_BINARY_DIR}/exp_generated4.c
|
|
|
|
DEPENDS exp_testExe4
|
|
|
|
)
|
2009-04-06 19:11:33 +04:00
|
|
|
|
|
|
|
add_executable(imp_testExe1
|
|
|
|
imp_testExe1.c
|
|
|
|
${Import_BINARY_DIR}/exp_generated.c
|
|
|
|
${Import_BINARY_DIR}/exp_generated3.c
|
2015-08-11 22:19:03 +03:00
|
|
|
${Import_BINARY_DIR}/exp_generated4.c
|
2009-04-06 19:11:33 +04:00
|
|
|
)
|
|
|
|
|
|
|
|
# Try linking to a library imported from the install tree.
|
2009-04-09 00:29:04 +04:00
|
|
|
target_link_libraries(imp_testExe1
|
|
|
|
exp_testLib2
|
|
|
|
exp_testLib3
|
|
|
|
exp_testLib4
|
|
|
|
exp_testLib5
|
2009-07-11 18:10:51 +04:00
|
|
|
exp_testLib6
|
2015-07-08 23:53:38 +03:00
|
|
|
exp_testLib7
|
2009-09-01 18:38:36 +04:00
|
|
|
exp_testLibCycleA
|
2015-02-11 22:02:45 +03:00
|
|
|
exp_testLibPerConfigDest
|
2009-04-09 00:29:04 +04:00
|
|
|
)
|
2009-04-06 19:11:33 +04:00
|
|
|
|
|
|
|
# Try building a plugin to an executable imported from the install tree.
|
|
|
|
add_library(imp_mod1 MODULE imp_mod1.c)
|
|
|
|
target_link_libraries(imp_mod1 exp_testExe2)
|
|
|
|
|
|
|
|
# Try referencing an executable imported from the build tree.
|
|
|
|
add_custom_command(
|
|
|
|
OUTPUT ${Import_BINARY_DIR}/bld_generated.c
|
|
|
|
COMMAND bld_testExe1 ${Import_BINARY_DIR}/bld_generated.c
|
|
|
|
DEPENDS bld_testExe1
|
|
|
|
)
|
|
|
|
add_custom_command(
|
|
|
|
OUTPUT ${Import_BINARY_DIR}/bld_generated3.c
|
|
|
|
COMMAND bld_testExe3 ${Import_BINARY_DIR}/bld_generated3.c
|
|
|
|
DEPENDS bld_testExe3
|
|
|
|
)
|
2015-08-11 22:19:03 +03:00
|
|
|
add_custom_command(
|
|
|
|
OUTPUT ${Import_BINARY_DIR}/bld_generated4.c
|
|
|
|
COMMAND bld_testExe4 ${Import_BINARY_DIR}/bld_generated4.c
|
|
|
|
DEPENDS bld_testExe4
|
|
|
|
)
|
2009-04-06 19:11:33 +04:00
|
|
|
|
|
|
|
add_executable(imp_testExe1b
|
|
|
|
imp_testExe1.c
|
|
|
|
${Import_BINARY_DIR}/bld_generated.c
|
|
|
|
${Import_BINARY_DIR}/bld_generated3.c
|
2015-08-11 22:19:03 +03:00
|
|
|
${Import_BINARY_DIR}/bld_generated4.c
|
2009-04-06 19:11:33 +04:00
|
|
|
)
|
|
|
|
|
|
|
|
# Try linking to a library imported from the build tree.
|
2009-04-09 00:29:04 +04:00
|
|
|
target_link_libraries(imp_testExe1b
|
|
|
|
bld_testLib2
|
|
|
|
bld_testLib3
|
|
|
|
bld_testLib4
|
|
|
|
bld_testLib5
|
2009-07-11 18:10:51 +04:00
|
|
|
bld_testLib6
|
2015-07-08 23:53:38 +03:00
|
|
|
bld_testLib7
|
2009-09-01 18:38:36 +04:00
|
|
|
bld_testLibCycleA
|
2015-02-11 22:02:45 +03:00
|
|
|
bld_testLibPerConfigDest
|
2009-04-09 00:29:04 +04:00
|
|
|
)
|
2009-04-06 19:11:33 +04:00
|
|
|
|
2014-02-22 01:47:34 +04:00
|
|
|
add_custom_target(check_testLib1_genex ALL
|
|
|
|
COMMAND ${CMAKE_COMMAND} -DtestLib1=$<TARGET_FILE:exp_testLib1>
|
|
|
|
-Dprefix=${CMAKE_INSTALL_PREFIX}
|
|
|
|
-P ${CMAKE_CURRENT_SOURCE_DIR}/check_testLib1_genex.cmake
|
|
|
|
)
|
|
|
|
|
2013-06-04 18:47:57 +04:00
|
|
|
add_executable(cmp0022OLD_test cmp0022OLD_test_vs6_1.cpp)
|
|
|
|
target_link_libraries(cmp0022OLD_test bld_cmp0022OLD)
|
|
|
|
add_executable(cmp0022NEW_test cmp0022NEW_test_vs6_1.cpp)
|
|
|
|
target_link_libraries(cmp0022NEW_test bld_cmp0022NEW)
|
|
|
|
|
|
|
|
add_executable(cmp0022OLD_exp_test cmp0022OLD_test_vs6_2.cpp)
|
|
|
|
target_link_libraries(cmp0022OLD_exp_test exp_cmp0022OLD)
|
|
|
|
add_executable(cmp0022NEW_exp_test cmp0022NEW_test_vs6_2.cpp)
|
|
|
|
target_link_libraries(cmp0022NEW_exp_test exp_cmp0022NEW)
|
|
|
|
|
2009-04-06 19:11:33 +04:00
|
|
|
# Try building a plugin to an executable imported from the build tree.
|
|
|
|
add_library(imp_mod1b MODULE imp_mod1.c)
|
|
|
|
target_link_libraries(imp_mod1b bld_testExe2)
|
|
|
|
|
|
|
|
# Export/CMakeLists.txt pretends the RelWithDebInfo (as well as Debug)
|
|
|
|
# configuration should link to debug libs.
|
|
|
|
foreach(c DEBUG RELWITHDEBINFO)
|
|
|
|
set_property(TARGET imp_testExe1 PROPERTY COMPILE_DEFINITIONS_${c} EXE_DBG)
|
|
|
|
set_property(TARGET imp_testExe1b PROPERTY COMPILE_DEFINITIONS_${c} EXE_DBG)
|
2012-08-13 21:50:14 +04:00
|
|
|
endforeach()
|
2009-04-06 19:11:33 +04:00
|
|
|
|
2014-12-15 17:52:48 +03:00
|
|
|
#-----------------------------------------------------------------------------
|
|
|
|
include(${CMAKE_INSTALL_PREFIX}/lib/expAbs/expAbs.cmake)
|
|
|
|
|
|
|
|
add_executable(imp_testExeAbs1
|
|
|
|
imp_testExeAbs1.c
|
|
|
|
)
|
|
|
|
target_link_libraries(imp_testExeAbs1
|
|
|
|
expAbs_testLibAbs1
|
|
|
|
)
|
|
|
|
|
2010-12-08 20:22:13 +03:00
|
|
|
#-----------------------------------------------------------------------------
|
2010-11-19 21:36:11 +03:00
|
|
|
# Create a custom target to generate a header for the libraries below.
|
2010-12-08 20:22:13 +03:00
|
|
|
# Drive the header generation through an indirect chain of imported
|
|
|
|
# target dependencies.
|
|
|
|
|
|
|
|
# testLib2tmp1.h
|
2010-11-19 21:36:11 +03:00
|
|
|
add_custom_command(
|
2010-12-08 20:22:13 +03:00
|
|
|
OUTPUT testLib2tmp1.h
|
2010-11-19 21:36:11 +03:00
|
|
|
VERBATIM COMMAND
|
2010-12-08 20:22:13 +03:00
|
|
|
${CMAKE_COMMAND} -E echo "extern int testLib2(void);" > testLib2tmp1.h
|
|
|
|
)
|
|
|
|
|
|
|
|
# hdr_testLib2tmp1 needs testLib2tmp1.h
|
|
|
|
add_custom_target(hdr_testLib2tmp1 DEPENDS testLib2tmp1.h)
|
|
|
|
|
|
|
|
# exp_testExe2 needs hdr_testLib2tmp1
|
|
|
|
add_dependencies(exp_testExe2 hdr_testLib2tmp1)
|
|
|
|
|
|
|
|
# testLib2tmp.h needs exp_testExe2
|
|
|
|
add_custom_command(
|
|
|
|
OUTPUT testLib2tmp.h
|
|
|
|
VERBATIM COMMAND exp_testExe2
|
|
|
|
COMMAND ${CMAKE_COMMAND} -E copy testLib2tmp1.h testLib2tmp.h
|
2010-11-19 21:36:11 +03:00
|
|
|
)
|
2010-12-08 20:22:13 +03:00
|
|
|
|
|
|
|
# hdr_testLib2tmp needs testLib2tmp.h
|
|
|
|
add_custom_target(hdr_testLib2tmp DEPENDS testLib2tmp.h)
|
|
|
|
|
|
|
|
add_library(dep_testLib2tmp UNKNOWN IMPORTED)
|
|
|
|
set_property(TARGET dep_testLib2tmp PROPERTY
|
|
|
|
IMPORTED_LOCATION ${CMAKE_CURRENT_BINARY_DIR}/testLib2tmp.h)
|
|
|
|
|
|
|
|
# dep_testLib2tmp needs hdr_testLib2tmp
|
|
|
|
add_dependencies(dep_testLib2tmp hdr_testLib2tmp)
|
|
|
|
|
|
|
|
# testLib2.h needs dep_testLib2tmp
|
|
|
|
add_custom_command(
|
|
|
|
OUTPUT testLib2.h
|
|
|
|
VERBATIM COMMAND ${CMAKE_COMMAND} -E copy testLib2tmp.h testLib2.h
|
|
|
|
DEPENDS dep_testLib2tmp
|
|
|
|
)
|
|
|
|
|
|
|
|
# hdr_testLib2 needs testLib2.h
|
2010-11-19 21:36:11 +03:00
|
|
|
add_custom_target(hdr_testLib2 DEPENDS testLib2.h)
|
|
|
|
|
|
|
|
add_library(dep_testLib2 UNKNOWN IMPORTED)
|
2010-12-08 20:22:13 +03:00
|
|
|
|
|
|
|
# dep_testLib2 needs hdr_testLib2
|
2010-11-19 21:36:11 +03:00
|
|
|
add_dependencies(dep_testLib2 hdr_testLib2)
|
2010-12-08 20:22:13 +03:00
|
|
|
|
|
|
|
# exp_testLib2 and bld_testLib2 both need dep_testLib2
|
2010-11-19 21:36:11 +03:00
|
|
|
add_dependencies(bld_testLib2 dep_testLib2)
|
|
|
|
add_dependencies(exp_testLib2 dep_testLib2)
|
|
|
|
|
2010-12-08 20:22:13 +03:00
|
|
|
#-----------------------------------------------------------------------------
|
2009-04-06 19:11:33 +04:00
|
|
|
# Create a library to be linked by another directory in this project
|
|
|
|
# to test transitive linking to otherwise invisible imported targets.
|
2010-12-08 20:22:13 +03:00
|
|
|
include_directories(${CMAKE_CURRENT_BINARY_DIR})
|
2009-04-06 19:11:33 +04:00
|
|
|
add_library(imp_lib1 STATIC imp_lib1.c)
|
|
|
|
target_link_libraries(imp_lib1 exp_testLib2)
|
|
|
|
add_library(imp_lib1b STATIC imp_lib1.c)
|
|
|
|
target_link_libraries(imp_lib1b bld_testLib2)
|
2012-02-17 02:35:43 +04:00
|
|
|
|
|
|
|
#-----------------------------------------------------------------------------
|
|
|
|
# Test that handling imported targets, including transitive dependencies,
|
|
|
|
# works in CheckFunctionExists (...and hopefully all other try_compile() checks
|
|
|
|
include(CheckFunctionExists)
|
|
|
|
unset(HAVE_TESTLIB1_FUNCTION CACHE)
|
|
|
|
set(CMAKE_REQUIRED_LIBRARIES exp_testLib2)
|
|
|
|
check_function_exists(testLib1 HAVE_TESTLIB1_FUNCTION)
|
|
|
|
if (NOT HAVE_TESTLIB1_FUNCTION)
|
|
|
|
message(SEND_ERROR "Using imported target testLib2 in check_function_exists() failed !")
|
|
|
|
endif()
|
2012-09-23 15:45:17 +04:00
|
|
|
|
|
|
|
#-----------------------------------------------------------------------------
|
|
|
|
# Test that dependent imported targets have usable
|
|
|
|
# INTERFACE_COMPILE_DEFINITIONS and INTERFACE_INCLUDE_DIRECTORIES
|
|
|
|
|
2013-01-10 20:11:12 +04:00
|
|
|
add_executable(deps_iface deps_iface.c)
|
|
|
|
target_link_libraries(deps_iface testLibDepends)
|
Allow generator expressions in LINK_INTERFACE_LIBRARIES.
The Config and IMPORTED_ variants may also contain generator
expressions.
If 'the implementation is the interface', then the result of
evaluating the expressions at generate time is used to populate
the IMPORTED_LINK_INTERFACE_LIBRARIES property.
1) In the case of non-static libraries, this is fine because the
user still has the option to populate the LINK_INTERFACE_LIBRARIES
with generator expressions if that is what is wanted.
2) In the case of static libraries, this prevents a footgun,
enforcing that the interface and the implementation are really
the same.
Otherwise, the LINK_LIBRARIES could contain a generator
expression which is evaluated with a different context at build
time, and when used as an imported target. That would mean that the
result of evaluating the INTERFACE_LINK_LIBRARIES property for
a static library would not necessarily be the 'link implementation'.
For example:
add_library(libone STATIC libone.cpp)
add_library(libtwo STATIC libtwo.cpp)
add_library(libthree STATIC libthree.cpp)
target_link_libraries(libtwo
$<$<STREQUAL:$<TARGET_PROPERTY:TYPE>,STATIC_LIBRARY>:libone>)
target_link_libraries(libthree libtwo)
If the LINK_LIBRARIES content was simply copied to the
IMPORTED_LINK_INTERFACE_LIBRARIES, then libthree links to libone, but
executables linking to libthree will not link to libone.
3) As the 'implementation is the interface' concept is to be
deprecated in the future anyway, this should be fine.
2013-01-04 16:36:18 +04:00
|
|
|
|
|
|
|
add_executable(deps_shared_iface deps_shared_iface.cpp)
|
|
|
|
target_link_libraries(deps_shared_iface testSharedLibDepends)
|
2013-01-19 14:21:14 +04:00
|
|
|
target_compile_definitions(deps_shared_iface
|
|
|
|
PRIVATE
|
|
|
|
$<$<BOOL:$<TARGET_PROPERTY:POSITION_INDEPENDENT_CODE>>:PIC_PROPERTY_IS_ON>
|
2013-01-20 20:09:29 +04:00
|
|
|
$<$<BOOL:$<TARGET_PROPERTY:CUSTOM_PROP>>:CUSTOM_PROPERTY_IS_ON>
|
2013-01-06 16:49:20 +04:00
|
|
|
$<$<STREQUAL:$<TARGET_PROPERTY:CUSTOM_STRING>,testcontent>:CUSTOM_STRING_IS_MATCH>
|
2013-01-19 14:21:14 +04:00
|
|
|
)
|
2013-01-12 03:00:42 +04:00
|
|
|
|
2013-06-10 18:20:22 +04:00
|
|
|
if(CMAKE_CXX_COMPILER_ID MATCHES "GNU")
|
|
|
|
target_compile_definitions(deps_shared_iface
|
|
|
|
PRIVATE
|
|
|
|
"DO_GNU_TESTS"
|
|
|
|
)
|
|
|
|
endif()
|
|
|
|
|
2013-01-12 15:13:19 +04:00
|
|
|
if (APPLE OR CMAKE_CXX_COMPILER_ID MATCHES "GNU")
|
|
|
|
include(CheckCXXCompilerFlag)
|
|
|
|
check_cxx_compiler_flag(-fPIE run_pic_test)
|
|
|
|
else()
|
|
|
|
if (CMAKE_CXX_COMPILER_ID MATCHES "PGI"
|
|
|
|
OR CMAKE_CXX_COMPILER_ID MATCHES "PathScale"
|
|
|
|
OR CMAKE_SYSTEM_NAME MATCHES "IRIX64"
|
|
|
|
OR CMAKE_CXX_COMPILER_ID MATCHES "Intel")
|
|
|
|
set(run_pic_test 0)
|
|
|
|
else()
|
|
|
|
set(run_pic_test 1)
|
|
|
|
endif()
|
|
|
|
endif()
|
|
|
|
|
2013-05-17 12:12:02 +04:00
|
|
|
add_executable(exp_renamed_test renamed_test.cpp)
|
|
|
|
target_link_libraries(exp_renamed_test exp_renamed)
|
|
|
|
|
|
|
|
add_executable(bld_renamed_test renamed_test.cpp)
|
|
|
|
target_link_libraries(bld_renamed_test bld_renamed)
|
|
|
|
|
2013-01-12 15:13:19 +04:00
|
|
|
if (run_pic_test)
|
|
|
|
target_compile_definitions(deps_shared_iface PRIVATE CHECK_PIC_WORKS)
|
|
|
|
endif()
|
|
|
|
|
2013-07-08 18:59:03 +04:00
|
|
|
if(APPLE)
|
|
|
|
add_subdirectory(framework_interface)
|
|
|
|
endif()
|
|
|
|
|
2013-01-12 03:00:42 +04:00
|
|
|
#-----------------------------------------------------------------------------
|
|
|
|
# Test that targets imported from the build tree have their dependencies
|
|
|
|
# evaluated correctly. The above already tests the same for the install tree.
|
|
|
|
|
|
|
|
add_executable(deps_shared_iface2 deps_shared_iface.cpp)
|
2013-01-12 15:11:29 +04:00
|
|
|
target_link_libraries(deps_shared_iface2 bld_testSharedLibDepends bld_subdirlib)
|
2013-06-10 18:20:22 +04:00
|
|
|
if(CMAKE_CXX_COMPILER_ID MATCHES "GNU")
|
|
|
|
target_compile_definitions(deps_shared_iface2
|
|
|
|
PRIVATE
|
|
|
|
"DO_GNU_TESTS"
|
|
|
|
)
|
|
|
|
endif()
|
2013-01-12 15:11:29 +04:00
|
|
|
target_compile_definitions(deps_shared_iface2
|
2012-11-05 15:43:28 +04:00
|
|
|
PRIVATE TEST_SUBDIR_LIB
|
2013-01-19 14:21:14 +04:00
|
|
|
$<$<BOOL:$<TARGET_PROPERTY:POSITION_INDEPENDENT_CODE>>:PIC_PROPERTY_IS_ON>
|
2013-01-20 20:09:29 +04:00
|
|
|
$<$<BOOL:$<TARGET_PROPERTY:CUSTOM_PROP>>:CUSTOM_PROPERTY_IS_ON>
|
2013-01-06 16:49:20 +04:00
|
|
|
$<$<STREQUAL:$<TARGET_PROPERTY:CUSTOM_STRING>,testcontent>:CUSTOM_STRING_IS_MATCH>
|
2013-01-12 15:11:29 +04:00
|
|
|
)
|
2013-06-10 15:21:14 +04:00
|
|
|
|
|
|
|
add_subdirectory(excludedFromAll)
|
|
|
|
|
|
|
|
add_executable(iface_test_bld iface_test.cpp)
|
|
|
|
target_link_libraries(iface_test_bld bld_testSharedLibDepends)
|
2015-04-23 17:53:39 +03:00
|
|
|
set_property(TARGET iface_test_bld PROPERTY NO_SYSTEM_FROM_IMPORTED 1)
|
2013-06-10 15:21:14 +04:00
|
|
|
|
|
|
|
set_property(TARGET bld_testSharedLibRequired APPEND PROPERTY
|
|
|
|
LINK_INTERFACE_LIBRARIES
|
|
|
|
excludedFromAll
|
|
|
|
)
|
|
|
|
get_target_property(_configs bld_testSharedLibRequired IMPORTED_CONFIGURATIONS)
|
|
|
|
foreach(_config ${_configs})
|
|
|
|
set_property(TARGET bld_testSharedLibRequired APPEND PROPERTY
|
|
|
|
IMPORTED_LINK_INTERFACE_LIBRARIES_${_config}
|
|
|
|
excludedFromAll
|
|
|
|
)
|
|
|
|
endforeach()
|
|
|
|
unset(_configs)
|
|
|
|
add_executable(iface_test_exp iface_test.cpp)
|
|
|
|
target_link_libraries(iface_test_exp testSharedLibDepends)
|
|
|
|
|
|
|
|
set_property(TARGET testSharedLibDepends APPEND PROPERTY
|
|
|
|
LINK_INTERFACE_LIBRARIES
|
|
|
|
excludedFromAll
|
|
|
|
)
|
|
|
|
get_target_property(_configs testSharedLibDepends IMPORTED_CONFIGURATIONS)
|
|
|
|
foreach(_config ${_configs})
|
|
|
|
set_property(TARGET testSharedLibDepends APPEND PROPERTY
|
|
|
|
IMPORTED_LINK_INTERFACE_LIBRARIES_${_config}
|
|
|
|
excludedFromAll
|
|
|
|
)
|
|
|
|
endforeach()
|
|
|
|
unset(_configs)
|
2013-08-29 12:28:09 +04:00
|
|
|
|
|
|
|
if (((CMAKE_C_COMPILER_ID STREQUAL GNU AND CMAKE_C_COMPILER_VERSION VERSION_GREATER 4.4)
|
|
|
|
OR CMAKE_C_COMPILER_ID STREQUAL Clang)
|
|
|
|
AND (CMAKE_GENERATOR STREQUAL "Unix Makefiles" OR CMAKE_GENERATOR STREQUAL "Ninja"))
|
|
|
|
include(CheckCXXCompilerFlag)
|
|
|
|
check_cxx_compiler_flag(-Wunused-variable run_sys_includes_test)
|
|
|
|
if(run_sys_includes_test)
|
|
|
|
# The Bullseye wrapper appears to break the -isystem effect.
|
|
|
|
execute_process(COMMAND ${CMAKE_CXX_COMPILER} --version OUTPUT_VARIABLE out ERROR_VARIABLE out)
|
|
|
|
if("x${out}" MATCHES "Bullseye")
|
|
|
|
set(run_sys_includes_test 0)
|
|
|
|
endif()
|
|
|
|
endif()
|
|
|
|
if (run_sys_includes_test)
|
|
|
|
add_executable(test_system_exp test_system.cpp)
|
|
|
|
target_link_libraries(test_system_exp exp_systemlib)
|
|
|
|
target_compile_options(test_system_exp PRIVATE -Wunused-variable -Werror=unused-variable)
|
|
|
|
|
|
|
|
unset(EXP_ERROR_VARIABLE CACHE)
|
|
|
|
try_compile(EXP_ERROR_VARIABLE
|
|
|
|
"${CMAKE_CURRENT_SOURCE_DIR}/test_system"
|
|
|
|
"${CMAKE_CURRENT_SOURCE_DIR}/test_system.cpp"
|
|
|
|
COMPILE_DEFINITIONS "-Wunused-variable -Werror=unused-variable"
|
|
|
|
LINK_LIBRARIES exp_systemlib
|
|
|
|
OUTPUT_VARIABLE OUTPUT
|
|
|
|
)
|
|
|
|
if(NOT EXP_ERROR_VARIABLE)
|
|
|
|
message(SEND_ERROR "EXP_ERROR_VARIABLE try_compile failed, but it was expected to succeed ${OUTPUT}.")
|
|
|
|
endif()
|
|
|
|
|
2015-01-23 03:53:16 +03:00
|
|
|
if(NOT CMAKE_CROSSCOMPILING)
|
|
|
|
unset(EXP_RUN_VAR CACHE)
|
|
|
|
unset(EXP_COMPILE_VAR CACHE)
|
|
|
|
try_run(EXP_RUN_VAR EXP_COMPILE_VAR
|
|
|
|
"${CMAKE_CURRENT_SOURCE_DIR}/test_system"
|
|
|
|
"${CMAKE_CURRENT_SOURCE_DIR}/test_system.cpp"
|
|
|
|
COMPILE_DEFINITIONS "-Wunused-variable -Werror=unused-variable"
|
|
|
|
LINK_LIBRARIES exp_systemlib
|
|
|
|
OUTPUT_VARIABLE OUTPUT
|
|
|
|
)
|
|
|
|
if(NOT EXP_COMPILE_VAR)
|
|
|
|
message(SEND_ERROR "try_run compile failed, but it was expected to succeed ${OUTPUT}.")
|
|
|
|
endif()
|
|
|
|
endif()
|
|
|
|
|
2013-08-29 12:28:09 +04:00
|
|
|
add_executable(test_system_bld test_system.cpp)
|
|
|
|
target_link_libraries(test_system_bld bld_systemlib)
|
|
|
|
target_compile_options(test_system_bld PRIVATE -Wunused-variable -Werror=unused-variable)
|
|
|
|
|
|
|
|
unset(BLD_ERROR_VARIABLE CACHE)
|
|
|
|
try_compile(BLD_ERROR_VARIABLE
|
|
|
|
"${CMAKE_CURRENT_SOURCE_DIR}/test_system"
|
|
|
|
"${CMAKE_CURRENT_SOURCE_DIR}/test_system.cpp"
|
|
|
|
COMPILE_DEFINITIONS "-Wunused-variable -Werror=unused-variable"
|
|
|
|
LINK_LIBRARIES bld_systemlib
|
|
|
|
OUTPUT_VARIABLE OUTPUT
|
|
|
|
)
|
|
|
|
if(NOT BLD_ERROR_VARIABLE)
|
|
|
|
message(SEND_ERROR "BLD_ERROR_VARIABLE try_compile failed, but it was expected to succeed.")
|
|
|
|
endif()
|
2015-01-23 03:53:16 +03:00
|
|
|
|
|
|
|
if(NOT CMAKE_CROSSCOMPILING)
|
|
|
|
unset(BLD_RUN_VAR CACHE)
|
|
|
|
unset(BLD_COMPILE_VAR CACHE)
|
|
|
|
try_run(BLD_RUN_VAR BLD_COMPILE_VAR
|
|
|
|
"${CMAKE_CURRENT_SOURCE_DIR}/test_system"
|
|
|
|
"${CMAKE_CURRENT_SOURCE_DIR}/test_system.cpp"
|
|
|
|
COMPILE_DEFINITIONS "-Wunused-variable -Werror=unused-variable"
|
|
|
|
LINK_LIBRARIES bld_systemlib
|
|
|
|
OUTPUT_VARIABLE OUTPUT
|
|
|
|
)
|
|
|
|
if(NOT BLD_COMPILE_VAR)
|
|
|
|
message(SEND_ERROR "try_run compile failed, but it was expected to succeed ${OUTPUT}.")
|
|
|
|
endif()
|
|
|
|
endif()
|
2013-08-29 12:28:09 +04:00
|
|
|
endif()
|
|
|
|
endif()
|