diff options
Diffstat (limited to 'Tests')
-rw-r--r-- | Tests/CMakeOnly/CheckLanguage/CMakeLists.txt | 18 | ||||
-rw-r--r-- | Tests/RunCMake/AutoExportDll/AutoExport.cmake | 6 | ||||
-rw-r--r-- | Tests/RunCMake/AutoExportDll/cppCLI.cxx | 22 | ||||
-rw-r--r-- | Tests/RunCMake/AutoExportDll/say.cxx | 8 | ||||
-rw-r--r-- | Tests/RunCMake/FindPkgConfig/FindPkgConfig_IMPORTED_TARGET.cmake | 22 |
5 files changed, 64 insertions, 12 deletions
diff --git a/Tests/CMakeOnly/CheckLanguage/CMakeLists.txt b/Tests/CMakeOnly/CheckLanguage/CMakeLists.txt index 90aa921..1570c37 100644 --- a/Tests/CMakeOnly/CheckLanguage/CMakeLists.txt +++ b/Tests/CMakeOnly/CheckLanguage/CMakeLists.txt @@ -18,16 +18,16 @@ if(APPLE) list(APPEND LANGUAGES OBJC OBJCXX) endif() -foreach(lang ${LANGUAGES}) - check_language(${lang}) - if(NOT DEFINED CMAKE_${lang}_COMPILER) - message(FATAL_ERROR "check_language(${lang}) did not set result") +foreach(test_lang ${LANGUAGES}) + check_language(${test_lang}) + if(NOT DEFINED CMAKE_${test_lang}_COMPILER) + message(FATAL_ERROR "check_language(${test_lang}) did not set result") endif() - if(DEFINED expect_${lang}) - if(expect_${lang} AND NOT CMAKE_${lang}_COMPILER) - message(FATAL_ERROR "check_language(${lang}) should not fail!") - elseif(NOT expect_${lang} AND CMAKE_${lang}_COMPILER) - message(FATAL_ERROR "check_language(${lang}) should not succeed!") + if(DEFINED expect_${test_lang}) + if(expect_${test_lang} AND NOT CMAKE_${test_lang}_COMPILER) + message(FATAL_ERROR "check_language(${test_lang}) should not fail!") + elseif(NOT expect_${test_lang} AND CMAKE_${test_lang}_COMPILER) + message(FATAL_ERROR "check_language(${test_lang}) should not succeed!") endif() endif() endforeach() diff --git a/Tests/RunCMake/AutoExportDll/AutoExport.cmake b/Tests/RunCMake/AutoExportDll/AutoExport.cmake index a550005..85eff7e 100644 --- a/Tests/RunCMake/AutoExportDll/AutoExport.cmake +++ b/Tests/RunCMake/AutoExportDll/AutoExport.cmake @@ -5,6 +5,10 @@ add_subdirectory(sub) add_library(objlib OBJECT objlib.c) set_property(TARGET objlib PROPERTY POSITION_INDEPENDENT_CODE 1) add_library(autoexport SHARED hello.cxx world.cxx foo.c $<TARGET_OBJECTS:objlib>) +add_library(autoexport3 SHARED cppCLI.cxx) +if(MSVC AND NOT MSVC_VERSION VERSION_LESS 1600) + set_property(TARGET autoexport3 PROPERTY COMMON_LANGUAGE_RUNTIME "") +endif() add_executable(say say.cxx) if(MSVC) @@ -18,4 +22,4 @@ if(MSVC) target_compile_definitions(say PRIVATE HAS_JUSTNOP) endif() endif() -target_link_libraries(say autoexport autoexport2) +target_link_libraries(say autoexport autoexport2 autoexport3) diff --git a/Tests/RunCMake/AutoExportDll/cppCLI.cxx b/Tests/RunCMake/AutoExportDll/cppCLI.cxx new file mode 100644 index 0000000..816bb6e --- /dev/null +++ b/Tests/RunCMake/AutoExportDll/cppCLI.cxx @@ -0,0 +1,22 @@ +#include <stdio.h> + +#ifdef __cplusplus_cli +# include <msclr\marshal_cppstd.h> + +void cliFunction() +{ + System::String ^ result = "cliFunction"; + result = result->Trim(); + printf(msclr::interop::marshal_as<std::string>(result).c_str()); +} +#else +void cliFunction() +{ + printf("cliFunction (but /cli was not passed to the compiler)"); +} +#endif + +void nonCliFunction() +{ + printf("nonCliFunction"); +} diff --git a/Tests/RunCMake/AutoExportDll/say.cxx b/Tests/RunCMake/AutoExportDll/say.cxx index 654b5e0..8fc768a 100644 --- a/Tests/RunCMake/AutoExportDll/say.cxx +++ b/Tests/RunCMake/AutoExportDll/say.cxx @@ -17,9 +17,11 @@ void justnop(); } // test c++ functions -// forward declare hello and world +// forward declare hello, world, cliFunction and nonCliFunction void hello(); void world(); +void cliFunction(); +void nonCliFunction(); // test exports for executable target extern "C" { @@ -44,6 +46,10 @@ int main() bar(); objlib(); printf("\n"); + cliFunction(); + printf("\n"); + nonCliFunction(); + printf("\n"); #ifdef HAS_JUSTNOP justnop(); #endif diff --git a/Tests/RunCMake/FindPkgConfig/FindPkgConfig_IMPORTED_TARGET.cmake b/Tests/RunCMake/FindPkgConfig/FindPkgConfig_IMPORTED_TARGET.cmake index 62bb5de..d697fc6 100644 --- a/Tests/RunCMake/FindPkgConfig/FindPkgConfig_IMPORTED_TARGET.cmake +++ b/Tests/RunCMake/FindPkgConfig/FindPkgConfig_IMPORTED_TARGET.cmake @@ -99,6 +99,7 @@ file(WRITE ${fakePkgDir}/lib/pkgconfig/${pname}.pc Description: Dummy package for FindPkgConfig IMPORTED_TARGET INTERFACE_LINK_OPTIONS test Version: 1.2.3 Libs: -e dummy_main +Cflags: -I/special -isystem /other -isystem/more -DA-isystem/foo ") set(expected_link_options -e dummy_main) @@ -109,7 +110,26 @@ endif() get_target_property(link_options PkgConfig::FakeLinkOptionsPackage INTERFACE_LINK_OPTIONS) if (NOT link_options STREQUAL expected_link_options) message(FATAL_ERROR - "Additional link options not present in INTERFACE_LINK_OPTIONS property" + "Additional link options not present in INTERFACE_LINK_OPTIONS property\n" "expected: \"${expected_link_options}\", but got \"${link_options}\"" ) endif() + +get_target_property(inc_dirs PkgConfig::FakeLinkOptionsPackage INTERFACE_INCLUDE_DIRECTORIES) +set(expected_inc_dirs "/special" "/other" "/more") + +if (NOT inc_dirs STREQUAL expected_inc_dirs) + message(FATAL_ERROR + "Additional include directories not correctly present in INTERFACE_INCLUDE_DIRECTORIES property\n" + "expected: \"${expected_inc_dirs}\", got \"${inc_dirs}\"" + ) +endif () + +get_target_property(c_opts PkgConfig::FakeLinkOptionsPackage INTERFACE_COMPILE_OPTIONS) +set(expected_c_opts "-DA-isystem/foo") # this is an invalid option, but a good testcase +if (NOT c_opts STREQUAL expected_c_opts) + message(FATAL_ERROR + "Additional compile options not present in INTERFACE_COMPILE_OPTIONS property\n" + "expected: \"${expected_c_opts}\", got \"${c_opts}\"" + ) +endif () |