Skip to content

Commit

Permalink
cmake: Make MacOS package
Browse files Browse the repository at this point in the history
- This fixes hi-res screen for Allegro5. See Allegro5 notes on building apps for OSX.
Use C++11 def to build C++11.
  • Loading branch information
billyquith committed Aug 2, 2016
1 parent 3714b44 commit cca52e2
Show file tree
Hide file tree
Showing 5 changed files with 49 additions and 39 deletions.
2 changes: 2 additions & 0 deletions CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -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)
Expand Down
1 change: 0 additions & 1 deletion source/gwork/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -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)
Expand Down
1 change: 0 additions & 1 deletion source/platform/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -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}
Expand Down
83 changes: 47 additions & 36 deletions source/samples/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -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 "$<TARGET_FILE_DIR:${SAMPLE_NAME}>/../Resources")
else()
set(APP_BUILD_TYPE )
set(APP_RESOURCE_PATH "$<TARGET_FILE_DIR:${SAMPLE_NAME}>")
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"
"$<TARGET_FILE_DIR:${SAMPLE_NAME}>"
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"
"$<TARGET_FILE_DIR:${SAMPLE_NAME}>"
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"
"$<TARGET_FILE_DIR:${SAMPLE_NAME}>"
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"
"$<TARGET_FILE_DIR:${SAMPLE_NAME}>"
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)
1 change: 0 additions & 1 deletion source/test/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down

0 comments on commit cca52e2

Please sign in to comment.