From ba8dbbfe37a76d473703ee5123bc048cee9d096f Mon Sep 17 00:00:00 2001 From: Jeremy Kniager Date: Thu, 17 May 2018 11:15:43 -0600 Subject: cmake: Update CMake files to build for MacOS Updated CMake scripts to add building for MacOS Change-Id: I413f79e337d33f37891092da97380597e28c8257 --- cube/macOS/common.cmake | 39 --------------------------------------- cube/macOS/cube/cube.cmake | 12 ++++++------ cube/macOS/cubepp/cubepp.cmake | 14 +++++++------- 3 files changed, 13 insertions(+), 52 deletions(-) delete mode 100644 cube/macOS/common.cmake (limited to 'cube/macOS') diff --git a/cube/macOS/common.cmake b/cube/macOS/common.cmake deleted file mode 100644 index 6a35db95..00000000 --- a/cube/macOS/common.cmake +++ /dev/null @@ -1,39 +0,0 @@ -# Set up common settings for building all demos on Apple platforms. - -# Source for the MoltenVK ICD library and JSON file -set(MOLTENVK_DIR "${PROJECT_SOURCE_DIR}/external/MoltenVK") - -# MoltenVK JSON File - -# Modify the ICD JSON file to adjust the library path. -# The ICD JSON file goes in the Resources/vulkan/icd.d directory, so adjust the -# library_path to the relative path to the Frameworks directory in the bundle.. -# The regex does: substitute ':"' with: -# ': "../../../Frameworks/' -add_custom_target(MoltenVK_icd-staging-json ALL - COMMAND mkdir -p ${CMAKE_CURRENT_BINARY_DIR}/staging-json - COMMAND sed -e "/\"library_path\":/s$:[[:space:]]*\"[[:space:]]*[\\.\\/]*$: \"..\\/..\\/..\\/Frameworks\\/$" - ${MOLTENVK_DIR}/MoltenVK/icd/MoltenVK_icd.json > - ${CMAKE_CURRENT_BINARY_DIR}/staging-json/MoltenVK_icd.json - VERBATIM - DEPENDS "${MOLTENVK_DIR}/MoltenVK/icd/MoltenVK_icd.json" -) -set_source_files_properties(${CMAKE_CURRENT_BINARY_DIR}/staging-json/MoltenVK_icd.json PROPERTIES - GENERATED TRUE -) - -find_library(COCOA NAMES Cocoa) - -# Locate Interface Builder Tool, needed to build things like Storyboards outside of Xcode. -if (NOT ${CMAKE_GENERATOR} MATCHES "^Xcode.*") - # Make sure we can find the 'ibtool' program. If we can NOT find it we - # skip generation of this project - find_program(IBTOOL ibtool HINTS "/usr/bin" "${OSX_DEVELOPER_ROOT}/usr/bin") - if (${IBTOOL} STREQUAL "IBTOOL-NOTFOUND") - message(SEND_ERROR - "ibtool can not be found and is needed to compile the .xib files. " - "It should have been installed with the Apple developer tools. " - "The default system paths were searched in addition to ${OSX_DEVELOPER_ROOT}/usr/bin." - ) - endif() -endif() diff --git a/cube/macOS/cube/cube.cmake b/cube/macOS/cube/cube.cmake index b298933b..11be95f4 100644 --- a/cube/macOS/cube/cube.cmake +++ b/cube/macOS/cube/cube.cmake @@ -11,7 +11,7 @@ set(cube_HDRS ) set(cube_RESOURCES ${CMAKE_CURRENT_SOURCE_DIR}/lunarg.ppm - ${CMAKE_CURRENT_BINARY_DIR}/staging-json/MoltenVK_icd.json + ${CMAKE_BINARY_DIR}/staging-json/MoltenVK_icd.json ${CMAKE_CURRENT_SOURCE_DIR}/macOS/cube/Resources/LunarGIcon.icns ) @@ -50,7 +50,7 @@ target_include_directories(cube PRIVATE ${MOLTENVK_DIR}/MoltenVK/include ) -target_link_libraries(cube ${LIBRARIES} "-framework Cocoa -framework QuartzCore") +target_link_libraries(cube ${LIBVK} "-framework Cocoa -framework QuartzCore") set_target_properties(cube PROPERTIES MACOSX_BUNDLE_INFO_PLIST ${CMAKE_CURRENT_SOURCE_DIR}/macOS/cube/Info.plist @@ -64,20 +64,20 @@ set_target_properties(cube PROPERTIES set_source_files_properties(${cube_RESOURCES} PROPERTIES MACOSX_PACKAGE_LOCATION "Resources" ) -set_source_files_properties("${CMAKE_CURRENT_BINARY_DIR}/staging-json/MoltenVK_icd.json" PROPERTIES +set_source_files_properties("${CMAKE_BINARY_DIR}/staging-json/MoltenVK_icd.json" PROPERTIES MACOSX_PACKAGE_LOCATION "Resources/vulkan/icd.d" ) # Copy the MoltenVK lib into the bundle. if(${CMAKE_GENERATOR} MATCHES "^Xcode.*") add_custom_command(TARGET cube POST_BUILD - COMMAND ${CMAKE_COMMAND} -E copy "${MOLTENVK_DIR}/MoltenVK/MacOS/libMoltenVK.dylib" + COMMAND ${CMAKE_COMMAND} -E copy "${MOLTENVK_DIR}/MoltenVK/macOS/libMoltenVK.dylib" ${CMAKE_CURRENT_BINARY_DIR}/$/cube.app/Contents/Frameworks/libMoltenVK.dylib DEPENDS vulkan ) else() add_custom_command(TARGET cube POST_BUILD - COMMAND ${CMAKE_COMMAND} -E copy "${MOLTENVK_DIR}/MoltenVK/MacOS/libMoltenVK.dylib" + COMMAND ${CMAKE_COMMAND} -E copy "${MOLTENVK_DIR}/MoltenVK/macOS/libMoltenVK.dylib" ${CMAKE_CURRENT_BINARY_DIR}/cube.app/Contents/Frameworks/libMoltenVK.dylib DEPENDS vulkan ) @@ -86,7 +86,7 @@ endif() # Fix up the library search path in the executable to find (loader) libraries in the bundle. install(CODE " include(BundleUtilities) - fixup_bundle(${CMAKE_INSTALL_PREFIX}/demos/cube.app \"\" \"\") + fixup_bundle(${CMAKE_INSTALL_PREFIX}/cube/cube.app \"\" \"\") " COMPONENT Runtime ) diff --git a/cube/macOS/cubepp/cubepp.cmake b/cube/macOS/cubepp/cubepp.cmake index 874ed25f..e61736ef 100644 --- a/cube/macOS/cubepp/cubepp.cmake +++ b/cube/macOS/cubepp/cubepp.cmake @@ -11,7 +11,7 @@ set(cubepp_HDRS ) set(cubepp_RESOURCES ${CMAKE_CURRENT_SOURCE_DIR}/lunarg.ppm - ${CMAKE_CURRENT_BINARY_DIR}/staging-json/MoltenVK_icd.json + ${CMAKE_BINARY_DIR}/staging-json/MoltenVK_icd.json ${CMAKE_CURRENT_SOURCE_DIR}/macOS/cubepp/Resources/LunarGIcon.icns ) @@ -50,7 +50,7 @@ target_include_directories(cubepp PRIVATE ${MOLTENVK_DIR}/MoltenVK/include ) -target_link_libraries(cubepp ${LIBRARIES} "-framework Cocoa -framework QuartzCore") +target_link_libraries(cubepp ${LIBVK} "-framework Cocoa -framework QuartzCore") set_target_properties(cubepp PROPERTIES MACOSX_BUNDLE_INFO_PLIST ${CMAKE_CURRENT_SOURCE_DIR}/macOS/cubepp/Info.plist @@ -64,12 +64,12 @@ set_target_properties(cubepp PROPERTIES set_source_files_properties(${cubepp_RESOURCES} PROPERTIES MACOSX_PACKAGE_LOCATION "Resources" ) -set_source_files_properties("${CMAKE_CURRENT_BINARY_DIR}/staging-json/MoltenVK_icd.json" PROPERTIES +set_source_files_properties("${CMAKE_BINARY_DIR}/staging-json/MoltenVK_icd.json" PROPERTIES MACOSX_PACKAGE_LOCATION "Resources/vulkan/icd.d" ) # Direct the MoltenVK library to the right place. -install(FILES "${MOLTENVK_DIR}/MoltenVK/MacOS/libMoltenVK.dylib" +install(FILES "${MOLTENVK_DIR}/MoltenVK/macOS/libMoltenVK.dylib" DESTINATION "demos/cubepp.app/Contents/Frameworks" COMPONENT Runtime ) @@ -77,13 +77,13 @@ install(FILES "${MOLTENVK_DIR}/MoltenVK/MacOS/libMoltenVK.dylib" # Copy the MoltenVK lib into the bundle. if(${CMAKE_GENERATOR} MATCHES "^Xcode.*") add_custom_command(TARGET cubepp POST_BUILD - COMMAND ${CMAKE_COMMAND} -E copy "${MOLTENVK_DIR}/MoltenVK/MacOS/libMoltenVK.dylib" + COMMAND ${CMAKE_COMMAND} -E copy "${MOLTENVK_DIR}/MoltenVK/macOS/libMoltenVK.dylib" ${CMAKE_CURRENT_BINARY_DIR}/$/cubepp.app/Contents/Frameworks/libMoltenVK.dylib DEPENDS vulkan ) else() add_custom_command(TARGET cubepp POST_BUILD - COMMAND ${CMAKE_COMMAND} -E copy "${MOLTENVK_DIR}/MoltenVK/MacOS/libMoltenVK.dylib" + COMMAND ${CMAKE_COMMAND} -E copy "${MOLTENVK_DIR}/MoltenVK/macOS/libMoltenVK.dylib" ${CMAKE_CURRENT_BINARY_DIR}/cubepp.app/Contents/Frameworks/libMoltenVK.dylib DEPENDS vulkan ) @@ -92,7 +92,7 @@ endif() # Fix up the library search path in the executable to find (loader) libraries in the bundle. install(CODE " include(BundleUtilities) - fixup_bundle(${CMAKE_INSTALL_PREFIX}/demos/cubepp.app \"\" \"\") + fixup_bundle(${CMAKE_INSTALL_PREFIX}/cube/cubepp.app \"\" \"\") " COMPONENT Runtime ) -- cgit v1.2.3