2012-11-20 13:58:15 +04:00
|
|
|
|
|
|
|
# Import targets from the exported build tree.
|
|
|
|
include(${Import_BINARY_DIR}/../Export/ExportInterfaceBuildTree.cmake)
|
|
|
|
|
2012-11-20 14:06:29 +04:00
|
|
|
# Import targets from the exported install tree.
|
|
|
|
include(${CMAKE_INSTALL_PREFIX}/lib/exp/expInterface.cmake)
|
|
|
|
|
2012-11-20 13:58:15 +04:00
|
|
|
add_library(define_iface INTERFACE)
|
|
|
|
set_property(TARGET define_iface PROPERTY
|
|
|
|
INTERFACE_COMPILE_DEFINITIONS DEFINE_IFACE_DEFINE)
|
|
|
|
|
|
|
|
add_executable(headeronlytest_bld headeronlytest.cpp)
|
2013-07-30 11:51:56 +04:00
|
|
|
target_link_libraries(headeronlytest_bld bld::headeronly)
|
2012-11-20 13:58:15 +04:00
|
|
|
|
2013-07-30 11:51:56 +04:00
|
|
|
set_property(TARGET bld::sharediface APPEND PROPERTY INTERFACE_LINK_LIBRARIES define_iface)
|
2012-11-20 13:58:15 +04:00
|
|
|
|
|
|
|
add_executable(interfacetest_bld interfacetest.cpp)
|
2013-07-30 11:51:56 +04:00
|
|
|
target_link_libraries(interfacetest_bld bld::sharediface)
|
2012-11-20 13:58:15 +04:00
|
|
|
|
2013-11-04 04:15:43 +04:00
|
|
|
include(CheckCSourceCompiles)
|
2012-11-20 13:58:15 +04:00
|
|
|
include(CheckCXXSourceCompiles)
|
|
|
|
|
|
|
|
macro(do_try_compile prefix)
|
|
|
|
|
2013-07-30 11:51:56 +04:00
|
|
|
set(CMAKE_REQUIRED_LIBRARIES ${prefix}::headeronly)
|
2012-11-20 13:58:15 +04:00
|
|
|
check_cxx_source_compiles(
|
|
|
|
"
|
|
|
|
#include \"headeronly.h\"
|
|
|
|
|
|
|
|
#ifndef HEADERONLY_DEFINE
|
|
|
|
#error Expected HEADERONLY_DEFINE
|
|
|
|
#endif
|
|
|
|
|
|
|
|
int main(int,char**)
|
|
|
|
{
|
|
|
|
HeaderOnly ho;
|
|
|
|
return ho.foo();
|
|
|
|
}
|
|
|
|
" ${prefix}IFACE_TRY_COMPILE)
|
|
|
|
|
|
|
|
if(NOT ${prefix}IFACE_TRY_COMPILE)
|
|
|
|
message(SEND_ERROR "${prefix} try_compile with IMPORTED INTERFACE target failed!\n\n${OUTPUT}")
|
|
|
|
endif()
|
2013-12-17 22:23:40 +04:00
|
|
|
|
2013-11-04 04:15:43 +04:00
|
|
|
if (";${CMAKE_C_COMPILE_FEATURES};" MATCHES ";c_restrict;")
|
|
|
|
set(CMAKE_REQUIRED_LIBRARIES ${prefix}::use_c_restrict)
|
|
|
|
check_c_source_compiles(
|
|
|
|
"
|
|
|
|
int foo(int * restrict a, int * restrict b)
|
|
|
|
{
|
|
|
|
(void)a;
|
|
|
|
(void)b;
|
|
|
|
return 0;
|
|
|
|
}
|
|
|
|
int main()
|
|
|
|
{
|
|
|
|
return 0;
|
|
|
|
}
|
|
|
|
" ${prefix}IMPORTED_IFACE_C_RESTRICT)
|
|
|
|
|
|
|
|
if(NOT ${prefix}IMPORTED_IFACE_C_RESTRICT)
|
|
|
|
message(SEND_ERROR "${prefix} try_compile with IMPORTED INTERFACE target failed!\n\n${OUTPUT}")
|
|
|
|
endif()
|
|
|
|
endif()
|
2013-12-17 22:23:40 +04:00
|
|
|
if (";${CMAKE_CXX_COMPILE_FEATURES};" MATCHES ";cxx_auto_type;")
|
|
|
|
set(CMAKE_REQUIRED_LIBRARIES ${prefix}::use_auto_type)
|
|
|
|
check_cxx_source_compiles(
|
|
|
|
"
|
|
|
|
int main(int,char**)
|
|
|
|
{
|
|
|
|
auto value = 0;
|
|
|
|
return value;
|
|
|
|
}
|
2014-05-06 23:20:49 +04:00
|
|
|
" ${prefix}IMPORTED_IFACE_AUTO_TYPE)
|
2013-12-17 22:23:40 +04:00
|
|
|
|
2014-05-06 23:20:49 +04:00
|
|
|
if(NOT ${prefix}IMPORTED_IFACE_AUTO_TYPE)
|
2013-12-17 22:23:40 +04:00
|
|
|
message(SEND_ERROR "${prefix} try_compile with IMPORTED INTERFACE target failed!\n\n${OUTPUT}")
|
|
|
|
endif()
|
|
|
|
endif()
|
|
|
|
|
2012-11-20 13:58:15 +04:00
|
|
|
endmacro()
|
|
|
|
|
2013-07-30 11:51:56 +04:00
|
|
|
do_try_compile(bld)
|
2012-11-20 14:06:29 +04:00
|
|
|
|
2014-11-28 20:58:38 +03:00
|
|
|
add_executable(source_target_test_bld source_target_test.cpp)
|
|
|
|
target_link_libraries(source_target_test_bld bld::source_target)
|
|
|
|
target_compile_definitions(source_target_test_bld PRIVATE USE_FROM_BUILD_DIR)
|
|
|
|
|
|
|
|
add_executable(source_target_test_exp source_target_test.cpp)
|
|
|
|
target_link_libraries(source_target_test_exp exp::source_target)
|
|
|
|
target_compile_definitions(source_target_test_exp PRIVATE USE_FROM_INSTALL_DIR)
|
|
|
|
|
2012-11-20 14:06:29 +04:00
|
|
|
add_executable(headeronlytest_exp headeronlytest.cpp)
|
2013-07-30 11:51:56 +04:00
|
|
|
target_link_libraries(headeronlytest_exp exp::headeronly)
|
2012-11-20 14:06:29 +04:00
|
|
|
|
2013-07-30 11:51:56 +04:00
|
|
|
set_property(TARGET exp::sharediface APPEND PROPERTY INTERFACE_LINK_LIBRARIES define_iface)
|
2012-11-20 14:06:29 +04:00
|
|
|
|
|
|
|
add_executable(interfacetest_exp interfacetest.cpp)
|
2013-07-30 11:51:56 +04:00
|
|
|
target_link_libraries(interfacetest_exp exp::sharediface)
|
2012-11-20 14:06:29 +04:00
|
|
|
|
2013-07-30 11:51:56 +04:00
|
|
|
do_try_compile(exp)
|