From 3ec8bab10efb8ffb403aa81b439e9635fe641f8f Mon Sep 17 00:00:00 2001 From: Manolo Gouy Date: Wed, 8 Apr 2015 12:16:52 +0000 Subject: [PATCH] CMake build on Mac OS: r10688 was not a good move because it works with the makefiles generator but not with the Xcode generator. Stepping back one commit. git-svn-id: file:///fltk/svn/fltk/branches/branch-1.3@10689 ea41ed52-d2ee-0310-a9c1-e6b18d33e121 --- CMake/macros.cmake | 28 ++++++++++++++++++++-------- test/CMakeLists.txt | 9 +-------- 2 files changed, 21 insertions(+), 16 deletions(-) diff --git a/CMake/macros.cmake b/CMake/macros.cmake index 623104d9a..ef45bc034 100644 --- a/CMake/macros.cmake +++ b/CMake/macros.cmake @@ -103,17 +103,22 @@ macro(CREATE_EXAMPLE NAME SOURCES LIBRARIES) endif(flsrcs) if(APPLE) - unset(ICON_NAME) + unset(RESOURCE_PATH) if(${tname} STREQUAL "blocks" OR ${tname} STREQUAL "checkers" OR ${tname} STREQUAL "sudoku") set( ICON_NAME ${tname}.icns ) + set( RESOURCE_PATH "${PROJECT_SOURCE_DIR}/test/${tname}.app/Contents/Resources/${ICON_NAME}" ) + elseif(${tname} STREQUAL "demo") + set( RESOURCE_PATH "${PROJECT_SOURCE_DIR}/test/demo.menu" ) endif(${tname} STREQUAL "blocks" OR ${tname} STREQUAL "checkers" OR ${tname} STREQUAL "sudoku") - add_executable(${tname} MACOSX_BUNDLE ${srcs} ${${tname}_FLTK_UI_SRCS}) - if(DEFINED ICON_NAME) - set_target_properties(${tname} PROPERTIES MACOSX_BUNDLE_ICON_FILE ${ICON_NAME}) - endif(DEFINED ICON_NAME) - if(${tname} STREQUAL "demo") - target_compile_definitions(demo PUBLIC USING_XCODE) - endif(${tname} STREQUAL "demo") + + if(DEFINED RESOURCE_PATH) + add_executable(${tname} MACOSX_BUNDLE ${srcs} ${RESOURCE_PATH}) + if(${tname} STREQUAL "demo") + target_compile_definitions(demo PUBLIC USING_XCODE) + endif(${tname} STREQUAL "demo") + else() + add_executable(${tname} MACOSX_BUNDLE ${srcs} ${${tname}_FLTK_UI_SRCS}) + endif(DEFINED RESOURCE_PATH) else() add_executable(${tname} WIN32 ${srcs} ${${tname}_FLTK_UI_SRCS}) endif(APPLE) @@ -121,6 +126,13 @@ macro(CREATE_EXAMPLE NAME SOURCES LIBRARIES) set_target_properties(${tname} PROPERTIES OUTPUT_NAME ${oname} ) + if(APPLE AND DEFINED RESOURCE_PATH) + if(NOT ${tname} STREQUAL "demo") + set_target_properties(${tname} PROPERTIES MACOSX_BUNDLE_ICON_FILE ${ICON_NAME}) + endif(NOT ${tname} STREQUAL "demo") + set_target_properties(${tname} PROPERTIES RESOURCE ${RESOURCE_PATH}) + endif(APPLE AND DEFINED RESOURCE_PATH) + target_link_libraries(${tname} ${LIBRARIES}) diff --git a/test/CMakeLists.txt b/test/CMakeLists.txt index ec924d827..82d67e27b 100644 --- a/test/CMakeLists.txt +++ b/test/CMakeLists.txt @@ -110,14 +110,7 @@ endif(FLTK_HAVE_CAIRO) # - maybe more ... # use a target filename to make sure the target directory gets created -if(APPLE) #copy files to bundle resources - configure_file(demo.menu ${EXECUTABLE_OUTPUT_PATH}/demo.app/Contents/Resources/demo.menu COPYONLY) - configure_file(blocks.app/Contents/Resources/blocks.icns ${EXECUTABLE_OUTPUT_PATH}/blocks.app/Contents/Resources/blocks.icns COPYONLY) - configure_file(checkers.app/Contents/Resources/checkers.icns ${EXECUTABLE_OUTPUT_PATH}/checkers.app/Contents/Resources/checkers.icns COPYONLY) - configure_file(sudoku.app/Contents/Resources/sudoku.icns ${EXECUTABLE_OUTPUT_PATH}/sudoku.app/Contents/Resources/sudoku.icns COPYONLY) -else() - configure_file(demo.menu ${EXECUTABLE_OUTPUT_PATH}/demo.menu COPYONLY) -endif(APPLE) +configure_file(demo.menu ${EXECUTABLE_OUTPUT_PATH}/demo.menu COPYONLY) # use target directory only to avoid redundancy configure_file(rgb.txt ${EXECUTABLE_OUTPUT_PATH} COPYONLY)