try_run: Add tests for LINK_LIBRARIES with mock libraries.
Extend the ExportImport test to try using an imported library with try_run.
This commit is contained in:
parent
223c5cb70b
commit
d0adcccbf4
|
@ -311,6 +311,21 @@ if (((CMAKE_C_COMPILER_ID STREQUAL GNU AND CMAKE_C_COMPILER_VERSION VERSION_GREA
|
||||||
message(SEND_ERROR "EXP_ERROR_VARIABLE try_compile failed, but it was expected to succeed ${OUTPUT}.")
|
message(SEND_ERROR "EXP_ERROR_VARIABLE try_compile failed, but it was expected to succeed ${OUTPUT}.")
|
||||||
endif()
|
endif()
|
||||||
|
|
||||||
|
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()
|
||||||
|
|
||||||
add_executable(test_system_bld test_system.cpp)
|
add_executable(test_system_bld test_system.cpp)
|
||||||
target_link_libraries(test_system_bld bld_systemlib)
|
target_link_libraries(test_system_bld bld_systemlib)
|
||||||
target_compile_options(test_system_bld PRIVATE -Wunused-variable -Werror=unused-variable)
|
target_compile_options(test_system_bld PRIVATE -Wunused-variable -Werror=unused-variable)
|
||||||
|
@ -326,5 +341,20 @@ if (((CMAKE_C_COMPILER_ID STREQUAL GNU AND CMAKE_C_COMPILER_VERSION VERSION_GREA
|
||||||
if(NOT BLD_ERROR_VARIABLE)
|
if(NOT BLD_ERROR_VARIABLE)
|
||||||
message(SEND_ERROR "BLD_ERROR_VARIABLE try_compile failed, but it was expected to succeed.")
|
message(SEND_ERROR "BLD_ERROR_VARIABLE try_compile failed, but it was expected to succeed.")
|
||||||
endif()
|
endif()
|
||||||
|
|
||||||
|
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()
|
||||||
endif()
|
endif()
|
||||||
endif()
|
endif()
|
||||||
|
|
Loading…
Reference in New Issue