diff options
Diffstat (limited to 'Tests/RunCMake')
-rw-r--r-- | Tests/RunCMake/XcodeProject/RunCMakeTest.cmake | 1 | ||||
-rw-r--r-- | Tests/RunCMake/XcodeProject/SearchPaths-check.cmake | 76 | ||||
-rw-r--r-- | Tests/RunCMake/XcodeProject/SearchPaths.cmake | 21 |
3 files changed, 98 insertions, 0 deletions
diff --git a/Tests/RunCMake/XcodeProject/RunCMakeTest.cmake b/Tests/RunCMake/XcodeProject/RunCMakeTest.cmake index abba741312..8e0a3bc87b 100644 --- a/Tests/RunCMake/XcodeProject/RunCMakeTest.cmake +++ b/Tests/RunCMake/XcodeProject/RunCMakeTest.cmake @@ -3,6 +3,7 @@ include(RunCMake) run_cmake(ExplicitCMakeLists) run_cmake(ImplicitCMakeLists) run_cmake(InterfaceLibSources) +run_cmake_with_options(SearchPaths -DCMAKE_CONFIGURATION_TYPES=Debug) run_cmake(XcodeFileType) run_cmake(XcodeAttributeLocation) diff --git a/Tests/RunCMake/XcodeProject/SearchPaths-check.cmake b/Tests/RunCMake/XcodeProject/SearchPaths-check.cmake new file mode 100644 index 0000000000..71b7d8faed --- /dev/null +++ b/Tests/RunCMake/XcodeProject/SearchPaths-check.cmake @@ -0,0 +1,76 @@ +set(xcProjectFile "${RunCMake_TEST_BINARY_DIR}/SearchPaths.xcodeproj/project.pbxproj") +if(NOT EXISTS "${xcProjectFile}") + set(RunCMake_TEST_FAILED "Project file ${xcProjectFile} does not exist.") + return() +endif() + +set(relevant_lines "") +set(found_project_FRAMEWORK_SEARCH_PATHS 0) +set(found_target_both_FRAMEWORK_SEARCH_PATHS 0) +set(found_target_include_FRAMEWORK_SEARCH_PATHS 0) +set(found_target_library_FRAMEWORK_SEARCH_PATHS 0) +set(found_inherited_FRAMEWORK_SEARCH_PATHS 0) +set(found_project_LIBRARY_SEARCH_PATHS 0) +set(found_target_library_LIBRARY_SEARCH_PATHS 0) +set(found_inherited_LIBRARY_SEARCH_PATHS 0) +file(STRINGS "${xcProjectFile}" lines) +foreach(line IN LISTS lines) + if(line MATCHES [[FRAMEWORK_SEARCH_PATHS]]) + string(APPEND relevant_lines " ${line}\n") + if(line MATCHES [[FRAMEWORK_SEARCH_PATHS = "[^"]*/Tests/RunCMake/XcodeProject/SearchPaths-build/ProjectSearchPath";]]) + set(found_project_FRAMEWORK_SEARCH_PATHS 1) + endif() + if(line MATCHES [[FRAMEWORK_SEARCH_PATHS = \("(\\")?[^"]*/Tests/RunCMake/XcodeProject/SearchPaths-build/TargetSearchPathInc(\\")?","(\\")?[^"]*/Tests/RunCMake/XcodeProject/SearchPaths-build/TargetSearchPathLib(\\")?","\$\(inherited\)"\);]]) + set(found_target_both_FRAMEWORK_SEARCH_PATHS 1) + endif() + if(line MATCHES [[FRAMEWORK_SEARCH_PATHS = \("(\\")?[^"]*/Tests/RunCMake/XcodeProject/SearchPaths-build/TargetSearchPathInc(\\")?","\$\(inherited\)"\);]]) + set(found_target_include_FRAMEWORK_SEARCH_PATHS 1) + endif() + if(line MATCHES [[FRAMEWORK_SEARCH_PATHS = \("(\\")?[^"]*/Tests/RunCMake/XcodeProject/SearchPaths-build/TargetSearchPathLib(\\")?","\$\(inherited\)"\);]]) + set(found_target_library_FRAMEWORK_SEARCH_PATHS 1) + endif() + if(line MATCHES [[FRAMEWORK_SEARCH_PATHS = \("\$\(inherited\)"\);]]) + set(found_inherited_FRAMEWORK_SEARCH_PATHS 1) + endif() + endif() + + if(line MATCHES [[LIBRARY_SEARCH_PATHS]]) + string(APPEND relevant_lines " ${line}\n") + if(line MATCHES [[LIBRARY_SEARCH_PATHS = "[^"]*/Tests/RunCMake/XcodeProject/SearchPaths-build/ProjectSearchPath";]]) + set(found_project_LIBRARY_SEARCH_PATHS 1) + endif() + if(line MATCHES [[LIBRARY_SEARCH_PATHS = \("(\\")?[^"]*/Tests/RunCMake/XcodeProject/SearchPaths-build/TargetSearchPathLib/\$\(CONFIGURATION\)\$\(EFFECTIVE_PLATFORM_NAME\)(\\")?","(\\")?[^"]*/Tests/RunCMake/XcodeProject/SearchPaths-build/TargetSearchPathLib(\\")?","\$\(inherited\)"\);]]) + set(found_target_library_LIBRARY_SEARCH_PATHS 1) + endif() + if(line MATCHES [[LIBRARY_SEARCH_PATHS = \("\$\(inherited\)"\);]]) + set(found_inherited_LIBRARY_SEARCH_PATHS 1) + endif() + endif() +endforeach() +if(NOT found_project_FRAMEWORK_SEARCH_PATHS) + string(APPEND RunCMake_TEST_FAILED "Did not find expected FRAMEWORK_SEARCH_PATHS for project in\n ${xcProjectFile}\n") +endif() +if(NOT found_target_both_FRAMEWORK_SEARCH_PATHS) + string(APPEND RunCMake_TEST_FAILED "Did not find expected FRAMEWORK_SEARCH_PATHS for target 'both' in\n ${xcProjectFile}\n") +endif() +if(NOT found_target_include_FRAMEWORK_SEARCH_PATHS) + string(APPEND RunCMake_TEST_FAILED "Did not find expected LIBRARY_SEARCH_PATHS for target 'include' in\n ${xcProjectFile}\n") +endif() +if(NOT found_target_library_FRAMEWORK_SEARCH_PATHS) + string(APPEND RunCMake_TEST_FAILED "Did not find expected LIBRARY_SEARCH_PATHS for target 'library' in\n ${xcProjectFile}\n") +endif() +if(found_inherited_FRAMEWORK_SEARCH_PATHS) + string(APPEND RunCMake_TEST_FAILED "Found unexpected LIBRARY_SEARCH_PATHS inherited-only value in\n ${xcProjectFile}\n") +endif() +if(NOT found_project_LIBRARY_SEARCH_PATHS) + string(APPEND RunCMake_TEST_FAILED "Did not find expected LIBRARY_SEARCH_PATHS for project in\n ${xcProjectFile}\n") +endif() +if(NOT found_target_library_LIBRARY_SEARCH_PATHS) + string(APPEND RunCMake_TEST_FAILED "Did not find expected LIBRARY_SEARCH_PATHS for target 'library' in\n ${xcProjectFile}\n") +endif() +if(found_inherited_LIBRARY_SEARCH_PATHS) + string(APPEND RunCMake_TEST_FAILED "Found unexpected LIBRARY_SEARCH_PATHS inherited-only value in\n ${xcProjectFile}\n") +endif() +if(RunCMake_TEST_FAILED) + string(APPEND RunCMake_TEST_FAILED "Relevant lines include\n${relevant_lines}") +endif() diff --git a/Tests/RunCMake/XcodeProject/SearchPaths.cmake b/Tests/RunCMake/XcodeProject/SearchPaths.cmake new file mode 100644 index 0000000000..ef977092be --- /dev/null +++ b/Tests/RunCMake/XcodeProject/SearchPaths.cmake @@ -0,0 +1,21 @@ +enable_language(C) + +file(MAKE_DIRECTORY "${CMAKE_CURRENT_BINARY_DIR}/ProjectSearchPath") +file(MAKE_DIRECTORY "${CMAKE_CURRENT_BINARY_DIR}/TargetSearchPathInc/TargetInc.framework") +file(MAKE_DIRECTORY "${CMAKE_CURRENT_BINARY_DIR}/TargetSearchPathLib/TargetLib.framework") + +set(CMAKE_XCODE_ATTRIBUTE_FRAMEWORK_SEARCH_PATHS "${CMAKE_CURRENT_BINARY_DIR}/ProjectSearchPath") +set(CMAKE_XCODE_ATTRIBUTE_LIBRARY_SEARCH_PATHS "${CMAKE_CURRENT_BINARY_DIR}/ProjectSearchPath") + +add_executable(neither main.c) + +add_executable(both main.c) +target_include_directories(both PRIVATE "${CMAKE_CURRENT_BINARY_DIR}/TargetSearchPathInc/TargetInc.framework") +target_link_libraries(both PRIVATE "${CMAKE_CURRENT_BINARY_DIR}/TargetSearchPathLib/TargetLib.framework") + +add_executable(include main.c) +target_include_directories(include PRIVATE "${CMAKE_CURRENT_BINARY_DIR}/TargetSearchPathInc/TargetInc.framework") + +add_executable(library main.c) +target_link_libraries(library PRIVATE "${CMAKE_CURRENT_BINARY_DIR}/TargetSearchPathLib/TargetLib.framework") +target_link_directories(library PRIVATE "${CMAKE_CURRENT_BINARY_DIR}/TargetSearchPathLib") |