diff options
author | Sebastian Holtermann <sebholt@xwmw.org> | 2019-09-08 12:58:35 +0200 |
---|---|---|
committer | Brad King <brad.king@kitware.com> | 2019-09-18 11:48:23 -0400 |
commit | 1933ade9f1624d6fa4b8a9bf128be96c75b57c68 (patch) | |
tree | d29fdb86ef29a8df4e596ac75d196c1ebf07a211 /Tests/QtAutogen | |
parent | 706d9738a614724a96487be074e984a7e86c48c9 (diff) | |
download | cmake-1933ade9f1624d6fa4b8a9bf128be96c75b57c68.tar.gz |
Tests: At QtAutogen.MocIncludeSymlink test
Diffstat (limited to 'Tests/QtAutogen')
-rw-r--r-- | Tests/QtAutogen/MocIncludeSymlink/CMakeLists.txt | 80 | ||||
-rw-r--r-- | Tests/QtAutogen/Tests.cmake | 1 |
2 files changed, 81 insertions, 0 deletions
diff --git a/Tests/QtAutogen/MocIncludeSymlink/CMakeLists.txt b/Tests/QtAutogen/MocIncludeSymlink/CMakeLists.txt new file mode 100644 index 0000000000..1627b394f2 --- /dev/null +++ b/Tests/QtAutogen/MocIncludeSymlink/CMakeLists.txt @@ -0,0 +1,80 @@ +cmake_minimum_required(VERSION 3.15) +project(MocIncludeSymlink) +include("../AutogenCoreTest.cmake") + +# +# Tests if MocInclude can be build when +# - The source directory is a symbolic link +# - The build directory is a symbolic link +# + +# -- Utility variables +set(CS_DIR "${CMAKE_CURRENT_SOURCE_DIR}") +set(CB_DIR "${CMAKE_CURRENT_BINARY_DIR}") + +# Absolute MocInclude path +get_filename_component(MocIncludePath "../MocInclude" ABSOLUTE) +message("MocIncludePath: ${MocIncludePath}") + +# Use nested subdirectories to ensure relatives paths are correct as well +set(BUILD_DIR_NORMAL "${CB_DIR}/Build/Normal") +set(BUILD_DIR_LINKED "${CB_DIR}/Build/Linked") + +set(SL_SOURCE_DIR "${CB_DIR}/SL_Source") +set(SL_BUILD_DIR "${CB_DIR}/SL_Build") + +# -- Utility macros +function(makeSymLink origin link) + message("Creating symbolic link\n Link: ${link}\n To: ${origin}") + file(CREATE_LINK ${origin} ${link} RESULT res SYMBOLIC) + if(NOT (${res} STREQUAL "0")) + message("Symlink creation failed.\n Link: ${link}\n To: ${origin}\n Result: ${res}") + endif() +endfunction() + +# -- Make source directory symlink +makeSymLink(${MocIncludePath} ${SL_SOURCE_DIR} linkResult) +if(NOT EXISTS ${SL_SOURCE_DIR}) + message("Directory symlink can't be created. Skipping test.") + return() +endif() + +# -- Make normal build directory +file(REMOVE_RECURSE ${BUILD_DIR_NORMAL}) +file(MAKE_DIRECTORY ${BUILD_DIR_NORMAL}) + +# -- Make linked build directory and symlink +file(REMOVE_RECURSE ${BUILD_DIR_LINKED}) +file(MAKE_DIRECTORY ${BUILD_DIR_LINKED}) +makeSymLink(${BUILD_DIR_LINKED} ${SL_BUILD_DIR} linkResult) +if(NOT EXISTS ${SL_BUILD_DIR}) + message("Directory symlink can't be created. Skipping test.") + return() +endif() + + +# -- Building +macro(buildMocInclude sourceDir binaryDir) + message("Building MocInclude\n - source dir: ${sourceDir}\n - binary dir: ${binaryDir}\n") + try_compile(result + "${binaryDir}" + "${sourceDir}" + MocInclude + CMAKE_FLAGS "-DQT_TEST_VERSION=${QT_TEST_VERSION}" + "-DCMAKE_AUTOGEN_VERBOSE=${CMAKE_AUTOGEN_VERBOSE}" + "-DQT_QMAKE_EXECUTABLE:FILEPATH=${QT_QMAKE_EXECUTABLE}" + OUTPUT_VARIABLE output + ) + if (result) + message(STATUS "--- Build success. ---") + else() + message(STATUS "\n### Building MocInclude failed. ###\n\n--- Output ---\n${output}") + message(FATAL_ERROR "--- Building MocInclude failed. End of output. ---") + endif() +endmacro() + +message("\nTry building with\n - symbolic link source dir\n - non symbolic build dir\n") +buildMocInclude(${SL_SOURCE_DIR} ${BUILD_DIR_NORMAL}) + +message("\nTry building with\n - symbolic link source dir\n - symbolic link build dir\n") +buildMocInclude(${SL_SOURCE_DIR} ${SL_BUILD_DIR}) diff --git a/Tests/QtAutogen/Tests.cmake b/Tests/QtAutogen/Tests.cmake index 04b50abe42..2b001d4523 100644 --- a/Tests/QtAutogen/Tests.cmake +++ b/Tests/QtAutogen/Tests.cmake @@ -33,6 +33,7 @@ ADD_AUTOGEN_TEST(UicSkipSource) if(QT_TEST_ALLOW_QT_MACROS) ADD_AUTOGEN_TEST(MocCMP0071) ADD_AUTOGEN_TEST(MocInclude) + ADD_AUTOGEN_TEST(MocIncludeSymlink) ADD_AUTOGEN_TEST(MocSkipSource) endif() |