From cca52e248d7c752de4ada8b24cd9a40cd85e8792 Mon Sep 17 00:00:00 2001 From: BQ Date: Tue, 2 Aug 2016 12:44:46 +0100 Subject: [PATCH] cmake: Make MacOS package - This fixes hi-res screen for Allegro5. See Allegro5 notes on building apps for OSX. Use C++11 def to build C++11. --- CMakeLists.txt | 2 + source/gwork/CMakeLists.txt | 1 - source/platform/CMakeLists.txt | 1 - source/samples/CMakeLists.txt | 83 +++++++++++++++++++--------------- source/test/CMakeLists.txt | 1 - 5 files changed, 49 insertions(+), 39 deletions(-) diff --git a/CMakeLists.txt b/CMakeLists.txt index a512c422..ba0343c3 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -20,6 +20,8 @@ set(CMAKE_LIBRARY_OUTPUT_DIRECTORY ${CMAKE_HOME_DIRECTORY}/bin) # .dylib set(CMAKE_ARCHIVE_OUTPUT_DIRECTORY ${CMAKE_HOME_DIRECTORY}/lib) # .a make_directory(${CMAKE_RUNTIME_OUTPUT_DIRECTORY}) make_directory(${CMAKE_LIBRARY_OUTPUT_DIRECTORY}) + +add_definitions(-std=c++11) # configure projects include(${CMAKE_SOURCE_DIR}/cmake/Config.cmake) diff --git a/source/gwork/CMakeLists.txt b/source/gwork/CMakeLists.txt index c0d57c1b..6b20b0c3 100644 --- a/source/gwork/CMakeLists.txt +++ b/source/gwork/CMakeLists.txt @@ -212,7 +212,6 @@ source_group("${GWK_SOURCE_FOLDER}\\Controls\\Dialog" # Gwork library add_library(Gwork STATIC ${GWK_HEADERS} ${GWK_SOURCES}) -target_compile_features(Gwork PUBLIC cxx_override) install(DIRECTORY ${CMAKE_CURRENT_SOURCE_DIR}/include/Gwork DESTINATION include) diff --git a/source/platform/CMakeLists.txt b/source/platform/CMakeLists.txt index 474fab01..4a428c27 100644 --- a/source/platform/CMakeLists.txt +++ b/source/platform/CMakeLists.txt @@ -33,7 +33,6 @@ source_group("${GWK_SOURCE_FOLDER}" # Gwork renderer & platform library add_library(Gwork${GWK_RENDER_NAME} STATIC ${GWK_RENDER_HEADERS} ${GWK_RENDER_SOURCES}) -target_compile_features(Gwork${GWK_RENDER_NAME} PUBLIC cxx_override) target_link_libraries(Gwork${GWK_RENDER_NAME} Gwork) install(FILES ${GWK_RENDER_HEADERS} diff --git a/source/samples/CMakeLists.txt b/source/samples/CMakeLists.txt index 4419b06b..96005c46 100644 --- a/source/samples/CMakeLists.txt +++ b/source/samples/CMakeLists.txt @@ -11,50 +11,61 @@ if(BUILD_SAMPLE) set(SAMPLE_SOURCES "${GWK_RENDER_NAME}/${GWK_RENDER_NAME}Sample.cpp") - set(SAMPLE_NAME Gwork${GWK_RENDER_NAME}Sample) + + if(APPLE) + set(APP_BUILD_TYPE MACOSX_BUNDLE) + set(APP_RESOURCE_PATH "$/../Resources") + else() + set(APP_BUILD_TYPE ) + set(APP_RESOURCE_PATH "$") + endif() - add_executable(${SAMPLE_NAME} ${SAMPLE_SOURCES}) - target_compile_features(${SAMPLE_NAME} PRIVATE cxx_override) + add_executable(${SAMPLE_NAME} ${APP_BUILD_TYPE} ${SAMPLE_SOURCES}) + target_link_libraries(${SAMPLE_NAME} - Gwork Gwork${GWK_RENDER_NAME} # GworkUtil + Gwork Gwork${GWK_RENDER_NAME} ${GWK_RENDER_LIBRARIES}) if(BUILD_TEST) target_link_libraries(${SAMPLE_NAME} GworkTest) endif(BUILD_TEST) + + if(APPLE) + set(APP_VERSION "0.1") + set(APP_COPYRIGHT "Copyright 2016 Bill Quith") + # make MacOS bundle + set_target_properties(${SAMPLE_NAME} PROPERTIES + MACOSX_BUNDLE_COPYRIGHT "${APP_COPYRIGHT}" + MACOSX_BUNDLE_INFO_STRING "${APP_VERSION}, ${APP_COPYRIGHT}" + MACOSX_BUNDLE_SHORT_VERSION_STRING "${APP_VERSION}" + MACOSX_BUNDLE_LONG_VERSION_STRING "${PROJECT_NAME} sample v${APP_VERSION}" + MACOSX_BUNDLE_GUI_IDENTIFIER "org.quith.${PROJECT_NAME}.${SAMPLE_NAME}" + ) + # set_source_files_properties(${DEMO_GFX} PROPERTIES + # MACOSX_PACKAGE_LOCATION "${APP_RESOURCE_DIR}/data/gfx" + # ) + endif() + + + macro(CopyAppResource RES_FROM WHAT) + get_filename_component(FNANE "${RES_FROM}" NAME) + add_custom_command( + TARGET ${SAMPLE_NAME} POST_BUILD + COMMAND ${CMAKE_COMMAND} -E copy "${RES_FROM}" "${APP_RESOURCE_PATH}/${FNANE}" + COMMENT "Copy ${WHAT}") + endmacro(CopyAppResource) + + CopyAppResource("${CMAKE_SOURCE_DIR}/source/gwork/resource/DefaultSkin.png" + "default skin") + + CopyAppResource("${CMAKE_SOURCE_DIR}/source/gwork/resource/OpenSans.ttf" + "default font") + + CopyAppResource("${CMAKE_SOURCE_DIR}/source/test/resource/gwen.png" + "test textures") - add_custom_command( - TARGET ${SAMPLE_NAME} POST_BUILD - COMMAND ${CMAKE_COMMAND} -E copy - "${CMAKE_SOURCE_DIR}/source/gwork/resource/DefaultSkin.png" - "$" - COMMENT "Copy default skin") - - add_custom_command( - TARGET ${SAMPLE_NAME} POST_BUILD - COMMAND ${CMAKE_COMMAND} -E copy - "${CMAKE_SOURCE_DIR}/source/gwork/resource/OpenSans.ttf" - "$" - COMMENT "Copy default font") - - add_custom_command( - TARGET ${SAMPLE_NAME} POST_BUILD - COMMAND ${CMAKE_COMMAND} -E copy - "${CMAKE_SOURCE_DIR}/source/test/resource/gwen.png" - "$" - COMMENT "Copy test textures") - - add_custom_command( - TARGET ${SAMPLE_NAME} POST_BUILD - COMMAND ${CMAKE_COMMAND} -E copy - "${CMAKE_SOURCE_DIR}/source/test/resource/test16.png" - "$" - COMMENT "Copy test textures") - - # install(TARGETS ${SAMPLE_NAME} - # RUNTIME DESTINATION bin - # LIBRARY DESTINATION lib - # ARCHIVE DESTINATION lib) + CopyAppResource("${CMAKE_SOURCE_DIR}/source/test/resource/test16.png" + "test textures") endif(BUILD_SAMPLE) diff --git a/source/test/CMakeLists.txt b/source/test/CMakeLists.txt index 6b04d9e6..7e3a2dfc 100644 --- a/source/test/CMakeLists.txt +++ b/source/test/CMakeLists.txt @@ -51,7 +51,6 @@ source_group("${GWK_SOURCE_FOLDER}" # Test library if(BUILD_TEST) add_library(GworkTest STATIC ${GWK_TEST_SOURCES}) - target_compile_features(GworkTest PUBLIC cxx_override) target_link_libraries(GworkTest Gwork Gwork${GWK_RENDER_NAME}) install(DIRECTORY ${CMAKE_CURRENT_SOURCE_DIR}/include/Gwork