diff options
Diffstat (limited to 'Tests')
-rw-r--r-- | Tests/FindTIFF/Test/CMakeLists.txt | 13 | ||||
-rw-r--r-- | Tests/FindTIFF/Test/main.cxx | 16 | ||||
-rw-r--r-- | Tests/FindVulkan/Test/CMakeLists.txt | 9 | ||||
-rw-r--r-- | Tests/FindVulkan/Test/Run-glslc.cmake | 20 | ||||
-rw-r--r-- | Tests/FindVulkan/Test/main.c | 4 | ||||
-rw-r--r-- | Tests/RunCMake/CMakeLists.txt | 2 | ||||
-rw-r--r-- | Tests/RunCMake/File_Archive/roundtrip.cmake | 24 | ||||
-rw-r--r-- | Tests/RunCMake/File_Archive/zip-filtered.cmake | 4 | ||||
-rw-r--r-- | Tests/RunCMake/File_Configure/RunCMakeTest.cmake | 1 | ||||
-rw-r--r-- | Tests/RunCMake/File_Configure/SubDir-check.cmake | 4 | ||||
-rw-r--r-- | Tests/RunCMake/File_Configure/SubDir.cmake | 1 | ||||
-rw-r--r-- | Tests/RunCMake/File_Configure/SubDir/CMakeLists.txt | 1 | ||||
-rw-r--r-- | Tests/RunCMake/configure_file/NoSourcePermissions.cmake | 10 | ||||
-rwxr-xr-x | Tests/RunCMake/configure_file/NoSourcePermissions.sh | 3 | ||||
-rw-r--r-- | Tests/RunCMake/configure_file/RunCMakeTest.cmake | 1 | ||||
-rw-r--r-- | Tests/RunCMake/find_library/LibSymLink-stderr.txt | 2 | ||||
-rw-r--r-- | Tests/RunCMake/find_library/LibSymLink.cmake | 17 | ||||
-rw-r--r-- | Tests/RunCMake/find_library/RunCMakeTest.cmake | 3 |
18 files changed, 115 insertions, 20 deletions
diff --git a/Tests/FindTIFF/Test/CMakeLists.txt b/Tests/FindTIFF/Test/CMakeLists.txt index 85453ed..e235db3 100644 --- a/Tests/FindTIFF/Test/CMakeLists.txt +++ b/Tests/FindTIFF/Test/CMakeLists.txt @@ -1,14 +1,23 @@ cmake_minimum_required(VERSION 3.1) -project(TestFindTIFF C) +project(TestFindTIFF) include(CTest) -find_package(TIFF REQUIRED) +find_package(TIFF REQUIRED COMPONENTS CXX) add_executable(test_tiff_tgt main.c) target_link_libraries(test_tiff_tgt TIFF::TIFF) add_test(NAME test_tiff_tgt COMMAND test_tiff_tgt) +add_executable(test_tiffxx_tgt main.cxx) +target_link_libraries(test_tiffxx_tgt TIFF::CXX) +add_test(NAME test_tiffxx_tgt COMMAND test_tiffxx_tgt) + add_executable(test_tiff_var main.c) target_include_directories(test_tiff_var PRIVATE ${TIFF_INCLUDE_DIRS}) target_link_libraries(test_tiff_var PRIVATE ${TIFF_LIBRARIES}) add_test(NAME test_tiff_var COMMAND test_tiff_var) + +add_executable(test_tiffxx_var main.cxx) +target_include_directories(test_tiffxx_var PRIVATE ${TIFF_INCLUDE_DIRS}) +target_link_libraries(test_tiffxx_var PRIVATE ${TIFF_LIBRARIES}) +add_test(NAME test_tiffxx_var COMMAND test_tiffxx_var) diff --git a/Tests/FindTIFF/Test/main.cxx b/Tests/FindTIFF/Test/main.cxx new file mode 100644 index 0000000..f80a31f --- /dev/null +++ b/Tests/FindTIFF/Test/main.cxx @@ -0,0 +1,16 @@ +#include <fstream> + +#include <assert.h> +#include <tiffio.hxx> + +int main() +{ + /* Without any TIFF file to open, test that the call fails as + expected. This tests that linking worked. */ + TIFF* tiff = TIFFOpen("invalid.tiff", "r"); + assert(!tiff); + + std::ifstream s; + TIFF* tiffxx = TIFFStreamOpen("invalid.tiff", &s); + return 0; +} diff --git a/Tests/FindVulkan/Test/CMakeLists.txt b/Tests/FindVulkan/Test/CMakeLists.txt index 0b13d53..9d36a0d 100644 --- a/Tests/FindVulkan/Test/CMakeLists.txt +++ b/Tests/FindVulkan/Test/CMakeLists.txt @@ -13,3 +13,12 @@ add_executable(test_var main.c) target_include_directories(test_var PRIVATE ${Vulkan_INCLUDE_DIRS}) target_link_libraries(test_var PRIVATE ${Vulkan_LIBRARIES}) add_test(NAME test_var COMMAND test_var) + +if(Vulkan_GLSLC_EXECUTABLE) + add_test(NAME test_glslc + COMMAND ${CMAKE_COMMAND} + "-DVULKAN_GLSLC_EXECUTABLE=${Vulkan_GLSLC_EXECUTABLE}" + "-DVULKAN_GLSLC_EXECUTABLE_TARGET=$<TARGET_FILE:Vulkan::glslc>" + -P "${CMAKE_CURRENT_LIST_DIR}/Run-glslc.cmake" + ) +endif() diff --git a/Tests/FindVulkan/Test/Run-glslc.cmake b/Tests/FindVulkan/Test/Run-glslc.cmake new file mode 100644 index 0000000..086eb9d --- /dev/null +++ b/Tests/FindVulkan/Test/Run-glslc.cmake @@ -0,0 +1,20 @@ +cmake_minimum_required(VERSION 3.12) + +function(run_glslc exe exe_display) + execute_process(COMMAND ${exe} --help + OUTPUT_VARIABLE output + OUTPUT_STRIP_TRAILING_WHITESPACE + RESULT_VARIABLE result + ) + + if(NOT result EQUAL 0) + message(SEND_ERROR "Result of ${exe_display} --help is ${result}, should be 0") + endif() + + if(NOT output MATCHES "^glslc - Compile shaders into SPIR-V") + message(SEND_ERROR "Output of ${exe_display} --help is \"${output}\", should begin with \"glslc - Compile shaders into SPIR-V\"") + endif() +endfunction() + +run_glslc("${VULKAN_GLSLC_EXECUTABLE}" "\${VULKAN_GLSLC_EXECUTABLE}") +run_glslc("${VULKAN_GLSLC_EXECUTABLE_TARGET}" "Vulkan::glslc") diff --git a/Tests/FindVulkan/Test/main.c b/Tests/FindVulkan/Test/main.c index b29c9ec..1bff651 100644 --- a/Tests/FindVulkan/Test/main.c +++ b/Tests/FindVulkan/Test/main.c @@ -2,10 +2,10 @@ int main() { - VkInstanceCreateInfo instanceCreateInfo = {}; + VkInstanceCreateInfo instanceCreateInfo = { 0 }; instanceCreateInfo.sType = VK_STRUCTURE_TYPE_INSTANCE_CREATE_INFO; - VkApplicationInfo applicationInfo = {}; + VkApplicationInfo applicationInfo = { 0 }; applicationInfo.sType = VK_STRUCTURE_TYPE_APPLICATION_INFO; applicationInfo.apiVersion = VK_API_VERSION_1_0; applicationInfo.applicationVersion = VK_MAKE_VERSION(1, 0, 0); diff --git a/Tests/RunCMake/CMakeLists.txt b/Tests/RunCMake/CMakeLists.txt index 192895b..fc337df 100644 --- a/Tests/RunCMake/CMakeLists.txt +++ b/Tests/RunCMake/CMakeLists.txt @@ -317,7 +317,7 @@ add_RunCMake_test(ctest_upload) add_RunCMake_test(ctest_fixtures) add_RunCMake_test(file) add_RunCMake_test(find_file) -add_RunCMake_test(find_library) +add_RunCMake_test(find_library -DCYGWIN=${CYGWIN}) add_RunCMake_test(find_package) add_RunCMake_test(find_path) add_RunCMake_test(find_program -DCMAKE_SYSTEM_NAME=${CMAKE_SYSTEM_NAME}) diff --git a/Tests/RunCMake/File_Archive/roundtrip.cmake b/Tests/RunCMake/File_Archive/roundtrip.cmake index f1b0de5..0638367 100644 --- a/Tests/RunCMake/File_Archive/roundtrip.cmake +++ b/Tests/RunCMake/File_Archive/roundtrip.cmake @@ -36,17 +36,17 @@ file(REMOVE_RECURSE ${FULL_DECOMPRESS_DIR}) file(MAKE_DIRECTORY ${FULL_DECOMPRESS_DIR}) file(ARCHIVE_CREATE - OUTPUT ${FULL_OUTPUT_NAME} - FORMAT "${ARCHIVE_FORMAT}" - COMPRESSION "${COMPRESSION_TYPE}" - VERBOSE - DIRECTORY ${COMPRESS_DIR}) + OUTPUT ${FULL_OUTPUT_NAME} + FORMAT "${ARCHIVE_FORMAT}" + COMPRESSION "${COMPRESSION_TYPE}" + VERBOSE + PATHS ${COMPRESS_DIR}) file(ARCHIVE_EXTRACT - INPUT ${FULL_OUTPUT_NAME} - ${DECOMPRESSION_OPTIONS} - DESTINATION ${FULL_DECOMPRESS_DIR} - VERBOSE) + INPUT ${FULL_OUTPUT_NAME} + ${DECOMPRESSION_OPTIONS} + DESTINATION ${FULL_DECOMPRESS_DIR} + VERBOSE) if(CUSTOM_CHECK_FILES) set(CHECK_FILES ${CUSTOM_CHECK_FILES}) @@ -57,11 +57,11 @@ foreach(file ${CHECK_FILES}) set(output ${FULL_DECOMPRESS_DIR}/${COMPRESS_DIR}/${file}) if(NOT EXISTS ${input}) - message(SEND_ERROR "Cannot find input file ${output}") + message(SEND_ERROR "Cannot find input file ${output}") endif() if(NOT EXISTS ${output}) - message(SEND_ERROR "Cannot find output file ${output}") + message(SEND_ERROR "Cannot find output file ${output}") endif() file(MD5 ${input} input_md5) @@ -76,7 +76,7 @@ foreach(file ${NOT_EXISTING_FILES_CHECK}) set(output ${FULL_DECOMPRESS_DIR}/${COMPRESS_DIR}/${file}) if(EXISTS ${output}) - message(SEND_ERROR "File ${output} exists but it shouldn't") + message(SEND_ERROR "File ${output} exists but it shouldn't") endif() endforeach() diff --git a/Tests/RunCMake/File_Archive/zip-filtered.cmake b/Tests/RunCMake/File_Archive/zip-filtered.cmake index e6bdcce..a4aab8b 100644 --- a/Tests/RunCMake/File_Archive/zip-filtered.cmake +++ b/Tests/RunCMake/File_Archive/zip-filtered.cmake @@ -3,9 +3,9 @@ set(OUTPUT_NAME "test.zip") set(ARCHIVE_FORMAT zip) set(DECOMPRESSION_OPTIONS - FILES + PATTERNS compress_dir/f1.txt # Decompress only file - compress_dir/d1 # and whole directory + compress_*/d? # and whole directory (has only one match) ) set(CUSTOM_CHECK_FILES diff --git a/Tests/RunCMake/File_Configure/RunCMakeTest.cmake b/Tests/RunCMake/File_Configure/RunCMakeTest.cmake index d09d648..0337014 100644 --- a/Tests/RunCMake/File_Configure/RunCMakeTest.cmake +++ b/Tests/RunCMake/File_Configure/RunCMakeTest.cmake @@ -7,3 +7,4 @@ run_cmake(DirOutput) run_cmake(NewLineStyle-NoArg) run_cmake(NewLineStyle-ValidArg) run_cmake(NewLineStyle-WrongArg) +run_cmake(SubDir) diff --git a/Tests/RunCMake/File_Configure/SubDir-check.cmake b/Tests/RunCMake/File_Configure/SubDir-check.cmake new file mode 100644 index 0000000..1e82587 --- /dev/null +++ b/Tests/RunCMake/File_Configure/SubDir-check.cmake @@ -0,0 +1,4 @@ +set(expected "${RunCMake_TEST_BINARY_DIR}/SubDir/out.txt") +if(NOT EXISTS "${expected}") + set(RunCMake_TEST_FAILED "Expected file not created:\n ${expected}") +endif() diff --git a/Tests/RunCMake/File_Configure/SubDir.cmake b/Tests/RunCMake/File_Configure/SubDir.cmake new file mode 100644 index 0000000..fae60fa --- /dev/null +++ b/Tests/RunCMake/File_Configure/SubDir.cmake @@ -0,0 +1 @@ +add_subdirectory(SubDir) diff --git a/Tests/RunCMake/File_Configure/SubDir/CMakeLists.txt b/Tests/RunCMake/File_Configure/SubDir/CMakeLists.txt new file mode 100644 index 0000000..6bd962e --- /dev/null +++ b/Tests/RunCMake/File_Configure/SubDir/CMakeLists.txt @@ -0,0 +1 @@ +file(CONFIGURE OUTPUT out.txt CONTENT "") diff --git a/Tests/RunCMake/configure_file/NoSourcePermissions.cmake b/Tests/RunCMake/configure_file/NoSourcePermissions.cmake new file mode 100644 index 0000000..c6ad131 --- /dev/null +++ b/Tests/RunCMake/configure_file/NoSourcePermissions.cmake @@ -0,0 +1,10 @@ +configure_file(NoSourcePermissions.sh NoSourcePermissions.sh.out + NO_SOURCE_PERMISSIONS) + +if (UNIX) + execute_process(COMMAND ${CMAKE_CURRENT_BINARY_DIR}/NoSourcePermissions.sh.out + RESULT_VARIABLE result) + if (result EQUAL "0") + message(FATAL_ERROR "Copied file has executable permissions") + endif() +endif() diff --git a/Tests/RunCMake/configure_file/NoSourcePermissions.sh b/Tests/RunCMake/configure_file/NoSourcePermissions.sh new file mode 100755 index 0000000..0aa8f41 --- /dev/null +++ b/Tests/RunCMake/configure_file/NoSourcePermissions.sh @@ -0,0 +1,3 @@ +#!/bin/sh + +#Testing NO_SOURCE_PERMISSIONS option of configure_file. diff --git a/Tests/RunCMake/configure_file/RunCMakeTest.cmake b/Tests/RunCMake/configure_file/RunCMakeTest.cmake index 32a0770..71694fb 100644 --- a/Tests/RunCMake/configure_file/RunCMakeTest.cmake +++ b/Tests/RunCMake/configure_file/RunCMakeTest.cmake @@ -15,6 +15,7 @@ run_cmake(NewLineStyle-NoArg) run_cmake(NewLineStyle-WrongArg) run_cmake(NewLineStyle-ValidArg) run_cmake(NewLineStyle-COPYONLY) +run_cmake(NoSourcePermissions) if(RunCMake_GENERATOR MATCHES "Make") # Use a single build tree for a few tests without cleaning. diff --git a/Tests/RunCMake/find_library/LibSymLink-stderr.txt b/Tests/RunCMake/find_library/LibSymLink-stderr.txt new file mode 100644 index 0000000..8a2f088 --- /dev/null +++ b/Tests/RunCMake/find_library/LibSymLink-stderr.txt @@ -0,0 +1,2 @@ +^SYMLINK_LIBRARY='SYMLINK_LIBRARY-NOTFOUND' +SYMLINK_LIBRARY='[^']*/Tests/RunCMake/find_library/LibSymLink-build/lib/libsymlink.a'$ diff --git a/Tests/RunCMake/find_library/LibSymLink.cmake b/Tests/RunCMake/find_library/LibSymLink.cmake new file mode 100644 index 0000000..8ee4b75 --- /dev/null +++ b/Tests/RunCMake/find_library/LibSymLink.cmake @@ -0,0 +1,17 @@ +list(APPEND CMAKE_FIND_LIBRARY_PREFIXES lib) +list(APPEND CMAKE_FIND_LIBRARY_SUFFIXES .a) +file(MAKE_DIRECTORY ${CMAKE_CURRENT_BINARY_DIR}/lib) +file(CREATE_LINK "libsymlinked.a" "${CMAKE_CURRENT_BINARY_DIR}/lib/libsymlink.a" SYMBOLIC) +find_library(SYMLINK_LIBRARY + NAMES symlink + PATHS ${CMAKE_CURRENT_BINARY_DIR}/lib + NO_DEFAULT_PATH + ) +message("SYMLINK_LIBRARY='${SYMLINK_LIBRARY}'") +file(WRITE "${CMAKE_CURRENT_BINARY_DIR}/lib/libsymlinked.a" "symlinked") +find_library(SYMLINK_LIBRARY + NAMES symlink + PATHS ${CMAKE_CURRENT_BINARY_DIR}/lib + NO_DEFAULT_PATH + ) +message("SYMLINK_LIBRARY='${SYMLINK_LIBRARY}'") diff --git a/Tests/RunCMake/find_library/RunCMakeTest.cmake b/Tests/RunCMake/find_library/RunCMakeTest.cmake index b6aadce..c7d69e4 100644 --- a/Tests/RunCMake/find_library/RunCMakeTest.cmake +++ b/Tests/RunCMake/find_library/RunCMakeTest.cmake @@ -3,8 +3,9 @@ include(RunCMake) run_cmake(Created) run_cmake(FromPrefixPath) run_cmake(FromPATHEnv) -if(CMAKE_HOST_UNIX) +if(UNIX AND NOT CYGWIN) run_cmake(LibArchLink) + run_cmake(LibSymLink) endif() run_cmake(PrefixInPATH) run_cmake(Required) |