diff options
Diffstat (limited to 'Tests')
-rw-r--r-- | Tests/CMakeLists.txt | 5 | ||||
-rw-r--r-- | Tests/FindCups/CMakeLists.txt | 10 | ||||
-rw-r--r-- | Tests/FindCups/Test/CMakeLists.txt | 16 | ||||
-rw-r--r-- | Tests/FindCups/Test/main.c | 12 | ||||
-rw-r--r-- | Tests/RunCMake/VS10Project/RunCMakeTest.cmake | 1 | ||||
-rw-r--r-- | Tests/RunCMake/VS10Project/VsCSharpCompilerOpts-check.cmake | 64 | ||||
-rw-r--r-- | Tests/RunCMake/VS10Project/VsCSharpCompilerOpts.cmake | 14 |
7 files changed, 122 insertions, 0 deletions
diff --git a/Tests/CMakeLists.txt b/Tests/CMakeLists.txt index ed98d97..8094c40 100644 --- a/Tests/CMakeLists.txt +++ b/Tests/CMakeLists.txt @@ -1413,6 +1413,10 @@ ${CMake_BINARY_DIR}/bin/cmake -DDIR=dev -P ${CMake_SOURCE_DIR}/Utilities/Release add_subdirectory(FindCURL) endif() + if(CMake_TEST_FindCups) + add_subdirectory(FindCups) + endif() + if(CMake_TEST_FindDoxygen) add_subdirectory(FindDoxygen) endif() @@ -3373,6 +3377,7 @@ ${CMake_BINARY_DIR}/bin/cmake -DDIR=dev -P ${CMake_SOURCE_DIR}/Utilities/Release --build-options ${build_options} -DCMake_TEST_NESTED_MAKE_PROGRAM:FILEPATH=${CMake_TEST_EXPLICIT_MAKE_PROGRAM} -DCMake_TEST_Fortran_SUBMODULES:BOOL=${CMake_TEST_Fortran_SUBMODULES} + ${CMake_TEST_FortranModules_BUILD_OPTIONS} ) list(APPEND TEST_BUILD_DIRS "${CMake_BINARY_DIR}/Tests/FortranModules") endif() diff --git a/Tests/FindCups/CMakeLists.txt b/Tests/FindCups/CMakeLists.txt new file mode 100644 index 0000000..5be1ac1 --- /dev/null +++ b/Tests/FindCups/CMakeLists.txt @@ -0,0 +1,10 @@ +add_test(NAME FindCups.Test COMMAND + ${CMAKE_CTEST_COMMAND} -C $<CONFIGURATION> + --build-and-test + "${CMake_SOURCE_DIR}/Tests/FindCups/Test" + "${CMake_BINARY_DIR}/Tests/FindCups/Test" + ${build_generator_args} + --build-project FindCups + --build-options ${build_options} + --test-command ${CMAKE_CTEST_COMMAND} -V -C $<CONFIGURATION> + ) diff --git a/Tests/FindCups/Test/CMakeLists.txt b/Tests/FindCups/Test/CMakeLists.txt new file mode 100644 index 0000000..9e90553 --- /dev/null +++ b/Tests/FindCups/Test/CMakeLists.txt @@ -0,0 +1,16 @@ +cmake_minimum_required(VERSION 3.10) +project(TestFindCups C) +include(CTest) + +find_package(Cups REQUIRED) + +add_definitions(-DCMAKE_EXPECTED_CUPS_VERSION="${CUPS_VERSION_STRING}") + +add_executable(test_tgt main.c) +target_link_libraries(test_tgt Cups::Cups) +add_test(NAME test_tgt COMMAND test_tgt) + +add_executable(test_var main.c) +target_include_directories(test_var PRIVATE ${CUPS_INCLUDE_DIRS}) +target_link_libraries(test_var PRIVATE ${CUPS_LIBRARIES}) +add_test(NAME test_var COMMAND test_var) diff --git a/Tests/FindCups/Test/main.c b/Tests/FindCups/Test/main.c new file mode 100644 index 0000000..b69d621 --- /dev/null +++ b/Tests/FindCups/Test/main.c @@ -0,0 +1,12 @@ +#include <cups/cups.h> + +int main() +{ + int num_options = 0; + cups_option_t* options = NULL; + + num_options = cupsAddOption(CUPS_COPIES, "1", num_options, &options); + cupsFreeOptions(num_options, options); + + return 0; +} diff --git a/Tests/RunCMake/VS10Project/RunCMakeTest.cmake b/Tests/RunCMake/VS10Project/RunCMakeTest.cmake index 7c1ed4e..df253a9 100644 --- a/Tests/RunCMake/VS10Project/RunCMakeTest.cmake +++ b/Tests/RunCMake/VS10Project/RunCMakeTest.cmake @@ -1,5 +1,6 @@ include(RunCMake) +run_cmake(VsCSharpCompilerOpts) run_cmake(ExplicitCMakeLists) run_cmake(SourceGroupCMakeLists) diff --git a/Tests/RunCMake/VS10Project/VsCSharpCompilerOpts-check.cmake b/Tests/RunCMake/VS10Project/VsCSharpCompilerOpts-check.cmake new file mode 100644 index 0000000..3e418c3 --- /dev/null +++ b/Tests/RunCMake/VS10Project/VsCSharpCompilerOpts-check.cmake @@ -0,0 +1,64 @@ +# +# Check C# VS project for required elements. +# +set(csProjectFile "${RunCMake_TEST_BINARY_DIR}/foo.csproj") +if(NOT EXISTS "${csProjectFile}") + set(RunCMake_TEST_FAILED "Project file ${csProjectFile} does not exist.") + return() +endif() + + +set(inDebug FALSE) +set(inRelease FALSE) +set(debugOK FALSE) +set(releaseOK FALSE) + + +file(STRINGS "${csProjectFile}" lines) +foreach(line IN LISTS lines) + #message(STATUS ${line}) + if(line MATCHES "^ *<PropertyGroup .*Debug\\|(Win32|x64).*") + set(inDebug TRUE) + elseif(line MATCHES "^ *<PropertyGroup .*Release\\|(Win32|x64).*") + set(inRelease TRUE) + elseif(line MATCHES "^ *</PropertyGroup> *$") + set(inRelease FALSE) + set(inDebug FALSE) + elseif(inDebug AND + (line MATCHES "^ *<NoWarn>.*505.*</NoWarn> *$") AND + (line MATCHES "^ *<NoWarn>.*707.*</NoWarn> *$") AND + (line MATCHES "^ *<NoWarn>.*808.*</NoWarn> *$") AND + (line MATCHES "^ *<NoWarn>.*909.*</NoWarn> *$") + ) + set(debugOK TRUE) + elseif(inRelease AND + (NOT (line MATCHES "^ *<NoWarn>.*505.*</NoWarn> *$")) AND + (line MATCHES "^ *<NoWarn>.*707.*</NoWarn> *$") AND + (line MATCHES "^ *<NoWarn>.*808.*</NoWarn> *$") AND + (line MATCHES "^ *<NoWarn>.*909.*</NoWarn> *$") + ) + set(releaseOK TRUE) + endif() +endforeach() + +function(print_csprojfile) + file(STRINGS "${csProjectFile}" lines) + foreach(line IN LISTS lines) + message(STATUS ${line}) + endforeach() +endfunction() + + +if(NOT debugOK) + message(STATUS "Failed to set Debug configuration warning config correctly.") + set(RunCMake_TEST_FAILED "Failed to set Debug configuration defines correctly.") + print_csprojfile() + return() +endif() + +if(NOT releaseOK) + message(STATUS "Failed to set Release configuration warning config correctly.") + set(RunCMake_TEST_FAILED "Failed to set Release configuration defines correctly.") + print_csprojfile() + return() +endif() diff --git a/Tests/RunCMake/VS10Project/VsCSharpCompilerOpts.cmake b/Tests/RunCMake/VS10Project/VsCSharpCompilerOpts.cmake new file mode 100644 index 0000000..85af38b --- /dev/null +++ b/Tests/RunCMake/VS10Project/VsCSharpCompilerOpts.cmake @@ -0,0 +1,14 @@ +enable_language(CSharp) + +add_library(foo SHARED + foo.cs) + +set_target_properties(foo PROPERTIES + LINKER_LANGUAGE CSharp) + + +# Issue 18878 +target_compile_options(foo PRIVATE "/platform:anycpu" "/nowarn:707,808" "/nowarn:909" ) + +# Debug only warning disable +set(CMAKE_CSharp_FLAGS_DEBUG "${CMAKE_CSharp_FLAGS_DEBUG} /nowarn:505") |