diff options
| author | Jeremy Kniager <jeremyk@lunarg.com> | 2018-05-17 11:15:43 -0600 |
|---|---|---|
| committer | jeremyk-lunarg <jeremyk@lunarg.com> | 2018-05-21 15:50:49 -0600 |
| commit | ba8dbbfe37a76d473703ee5123bc048cee9d096f (patch) | |
| tree | 6bed4832162e3e9a0759ed1b8e418f4c35d6935c /cube | |
| parent | 9f377cd6236f47bc5403431f81e323c2b8a489b2 (diff) | |
| download | usermoji-ba8dbbfe37a76d473703ee5123bc048cee9d096f.tar.xz | |
cmake: Update CMake files to build for MacOS
Updated CMake scripts to add building for MacOS
Change-Id: I413f79e337d33f37891092da97380597e28c8257
Diffstat (limited to 'cube')
| -rw-r--r-- | cube/CMakeLists.txt | 46 | ||||
| -rw-r--r-- | cube/macOS/common.cmake | 39 | ||||
| -rw-r--r-- | cube/macOS/cube/cube.cmake | 12 | ||||
| -rw-r--r-- | cube/macOS/cubepp/cubepp.cmake | 14 |
4 files changed, 34 insertions, 77 deletions
diff --git a/cube/CMakeLists.txt b/cube/CMakeLists.txt index f907a9a8..c90ab904 100644 --- a/cube/CMakeLists.txt +++ b/cube/CMakeLists.txt @@ -138,31 +138,27 @@ file(COPY ${TEXTURES} DESTINATION ${CMAKE_CURRENT_BINARY_DIR}) set (CMAKE_C_FLAGS "${CMAKE_C_FLAGS}") set (CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS}") -if(APPLE) - # TODO: Set libs for apple -else() - if(DEFINED LOADER_REPO_ROOT) - message(STATUS "Using user-supplied path to locate Vulkan") - if(WIN32) - set (LOADER_SEARCH_PATHS - "${LOADER_REPO_ROOT}/${BUILDTGT_DIR}/loader/${DEBUG_DECORATION}" - "${LOADER_REPO_ROOT}/${BUILDTGT_DIR}/loader/${RELEASE_DECORATION}" - ) - elseif(UNIX) - set (LOADER_SEARCH_PATHS - "${LOADER_REPO_ROOT}/${BUILDTGT_DIR}/loader" - ) - endif() - - find_library(LIBVK NAMES vulkan vulkan-1 - HINTS ${LOADER_SEARCH_PATHS} +if(DEFINED LOADER_REPO_ROOT) + message(STATUS "Using user-supplied path to locate Vulkan") + if(WIN32) + set (LOADER_SEARCH_PATHS + "${LOADER_REPO_ROOT}/${BUILDTGT_DIR}/loader/${DEBUG_DECORATION}" + "${LOADER_REPO_ROOT}/${BUILDTGT_DIR}/loader/${RELEASE_DECORATION}" ) - message(STATUS "Found Vulkan: ${LIBVK}") else() - message(STATUS "Using find_package to locate Vulkan") - find_package(Vulkan) - set (LIBVK "Vulkan::Vulkan") + set (LOADER_SEARCH_PATHS + "${LOADER_REPO_ROOT}/${BUILDTGT_DIR}/loader" + ) endif() + + find_library(LIBVK NAMES vulkan vulkan-1 + HINTS ${LOADER_SEARCH_PATHS} + ) + message(STATUS "Found Vulkan: ${LIBVK}") +else() + message(STATUS "Using find_package to locate Vulkan") + find_package(Vulkan) + set (LIBVK "Vulkan::Vulkan") endif() if(WIN32) @@ -200,9 +196,9 @@ if(WIN32) endif() # MacOS setup -if(APPLE) - include(macOS/common.cmake) -endif() +#if(APPLE) +# include(macOS/common.cmake) +#endif() include_directories( ${CUBE_INCLUDE_DIRS} 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 ':<whitespace>"<whitespace><all occurences of . and />' 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}/$<CONFIG>/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}/$<CONFIG>/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 ) |
