From 62c6178029cfe6dfb3bbb7bbd3da557da2cfe8d2 Mon Sep 17 00:00:00 2001 From: Petr Pokorny Date: Sun, 7 Feb 2021 20:53:38 +0100 Subject: [PATCH] Fixing cmake targets for XCode 12 - making sure unit tests can be run from macos project workspace. --- benchmark/CMakeLists.txt | 13 +++++++++++++ platform/ios/CMakeLists.txt | 2 -- .../ios/platform/ios/ios.xcodeproj/project.pbxproj | 2 +- platform/macos/macos.cmake | 2 ++ render-test/CMakeLists.txt | 10 ++++++++++ test/CMakeLists.txt | 10 ++++++++++ 6 files changed, 36 insertions(+), 3 deletions(-) diff --git a/benchmark/CMakeLists.txt b/benchmark/CMakeLists.txt index ab21fe33026..8b6d28f5940 100644 --- a/benchmark/CMakeLists.txt +++ b/benchmark/CMakeLists.txt @@ -38,6 +38,19 @@ if(CMAKE_SYSTEM_NAME STREQUAL iOS) set_target_properties(mbgl-benchmark PROPERTIES XCODE_ATTRIBUTE_ONLY_ACTIVE_ARCH $<$:YES>) endif() +if(CMAKE_SYSTEM_NAME STREQUAL Darwin) + set_target_properties(mbgl-benchmark mbgl-vendor-benchmark + PROPERTIES + XCODE_ATTRIBUTE_ONLY_ACTIVE_ARCH $<$:YES> + ) + set_target_properties(mbgl-benchmark mbgl-vendor-benchmark + PROPERTIES + ARCHIVE_OUTPUT_DIRECTORY "${CMAKE_BINARY_DIR}" + LIBRARY_OUTPUT_DIRECTORY "${CMAKE_BINARY_DIR}" + RUNTIME_OUTPUT_DIRECTORY "${CMAKE_BINARY_DIR}" + ) +endif() + # Needed for testing private classes get_target_property(MBGL_CORE_PRIVATE_LIBRARIES mbgl-core LINK_LIBRARIES) diff --git a/platform/ios/CMakeLists.txt b/platform/ios/CMakeLists.txt index 75ab9f173f8..443ff20ad30 100644 --- a/platform/ios/CMakeLists.txt +++ b/platform/ios/CMakeLists.txt @@ -1,7 +1,5 @@ cmake_minimum_required(VERSION 3.19) -message(source-dir=${CMAKE_SOURCE_DIR} current-dir=${CMAKE_CURRENT_SOURCE_DIR} current-binary-dir=${CMAKE_CURRENT_BINARY_DIR}) - add_subdirectory(${CMAKE_CURRENT_SOURCE_DIR}/../../ ${CMAKE_CURRENT_BINARY_DIR}/mapbox-gl-native ) project (mbgl) \ No newline at end of file diff --git a/platform/ios/platform/ios/ios.xcodeproj/project.pbxproj b/platform/ios/platform/ios/ios.xcodeproj/project.pbxproj index 1377686417d..62d5c2dbd7b 100644 --- a/platform/ios/platform/ios/ios.xcodeproj/project.pbxproj +++ b/platform/ios/platform/ios/ios.xcodeproj/project.pbxproj @@ -3712,7 +3712,7 @@ "CODE_SIGN_IDENTITY[sdk=iphoneos*]" = "iPhone Developer"; COPY_PHASE_STRIP = NO; CURRENT_PROJECT_VERSION = 15256; - DEBUG_INFORMATION_FORMAT = dwarf; + DEBUG_INFORMATION_FORMAT = "dwarf-with-dsym"; ENABLE_TESTABILITY = YES; GCC_OPTIMIZATION_LEVEL = 0; GCC_PREPROCESSOR_DEFINITIONS = ( diff --git a/platform/macos/macos.cmake b/platform/macos/macos.cmake index 03192d8037c..f2dec742e16 100644 --- a/platform/macos/macos.cmake +++ b/platform/macos/macos.cmake @@ -1,3 +1,4 @@ +cmake_minimum_required(VERSION 3.19) set(CMAKE_OSX_DEPLOYMENT_TARGET "10.11") # Override default CMake NATIVE_ARCH_ACTUAL @@ -149,6 +150,7 @@ target_link_libraries( set_property(TARGET mbgl-benchmark-runner PROPERTY FOLDER Executables) set_property(TARGET mbgl-test-runner PROPERTY FOLDER Executables) set_property(TARGET mbgl-render-test-runner PROPERTY FOLDER Executables) +set_target_properties(mbgl-benchmark-runner mbgl-test-runner mbgl-render-test-runner PROPERTIES XCODE_ATTRIBUTE_ONLY_ACTIVE_ARCH[variant=Debug] "YES") # Disable benchmarks in CI as they run in VM environment if(NOT DEFINED ENV{CI}) diff --git a/render-test/CMakeLists.txt b/render-test/CMakeLists.txt index 914199a7a02..cb00f19e17a 100644 --- a/render-test/CMakeLists.txt +++ b/render-test/CMakeLists.txt @@ -25,6 +25,16 @@ if(CMAKE_SYSTEM_NAME STREQUAL iOS) set_target_properties(mbgl-render-test PROPERTIES XCODE_ATTRIBUTE_ONLY_ACTIVE_ARCH $<$:YES>) endif() +if(CMAKE_SYSTEM_NAME STREQUAL Darwin) + set_target_properties(mbgl-render-test PROPERTIES XCODE_ATTRIBUTE_ONLY_ACTIVE_ARCH $<$:YES>) + set_target_properties(mbgl-render-test + PROPERTIES + ARCHIVE_OUTPUT_DIRECTORY "${CMAKE_BINARY_DIR}" + LIBRARY_OUTPUT_DIRECTORY "${CMAKE_BINARY_DIR}" + RUNTIME_OUTPUT_DIRECTORY "${CMAKE_BINARY_DIR}" + ) +endif() + # FIXME: Should not use core private interface target_include_directories( mbgl-render-test diff --git a/test/CMakeLists.txt b/test/CMakeLists.txt index 2ead99e4d83..95cdd94affc 100644 --- a/test/CMakeLists.txt +++ b/test/CMakeLists.txt @@ -197,6 +197,16 @@ if(CMAKE_SYSTEM_NAME STREQUAL iOS) set_target_properties(mbgl-test PROPERTIES XCODE_ATTRIBUTE_ONLY_ACTIVE_ARCH $<$:YES>) endif() +if(CMAKE_SYSTEM_NAME STREQUAL Darwin) + set_target_properties(mbgl-test mbgl-vendor-googletest PROPERTIES XCODE_ATTRIBUTE_ONLY_ACTIVE_ARCH $<$:YES>) + set_target_properties(mbgl-test mbgl-vendor-googletest + PROPERTIES + ARCHIVE_OUTPUT_DIRECTORY "${CMAKE_BINARY_DIR}" + LIBRARY_OUTPUT_DIRECTORY "${CMAKE_BINARY_DIR}" + RUNTIME_OUTPUT_DIRECTORY "${CMAKE_BINARY_DIR}" + ) +endif() + # Needed for testing private classes get_target_property(MBGL_CORE_PRIVATE_LIBRARIES mbgl-core LINK_LIBRARIES)