CMake support for building OS X framework

This commit is contained in:
stopiccot 2016-03-19 06:44:44 +03:00
parent c4bade8726
commit 30df027756

View File

@ -13,8 +13,11 @@ endif()
set(CMAKE_DEBUG_POSTFIX d) set(CMAKE_DEBUG_POSTFIX d)
option (BUILD_UTILS "utilities" ON) option (BUILD_UTILS "utilities" ON)
option (GLEW_REGAL "Regal mode" FALSE) option (GLEW_REGAL "Regal mode" OFF)
option (GLEW_OSMESA "OSMesa mode" FALSE) option (GLEW_OSMESA "OSMesa mode" OFF)
if (APPLE)
option (BUILD_FRAMEWORK "Build Framework bundle for OSX" OFF)
endif ()
set (GLEW_DIR ${CMAKE_CURRENT_SOURCE_DIR}/../..) set (GLEW_DIR ${CMAKE_CURRENT_SOURCE_DIR}/../..)
@ -74,16 +77,18 @@ endif ()
include_directories (${GLEW_DIR}/include) include_directories (${GLEW_DIR}/include)
set (GLEW_PUBLIC_HEADERS_FILES ${GLEW_DIR}/include/GL/wglew.h ${GLEW_DIR}/include/GL/glew.h ${GLEW_DIR}/include/GL/glxew.h)
set (GLEW_SRC_FILES ${GLEW_DIR}/src/glew.c) set (GLEW_SRC_FILES ${GLEW_DIR}/src/glew.c)
if (WIN32) if (WIN32)
list (APPEND GLEW_SRC_FILES ${GLEW_DIR}/build/glew.rc) list (APPEND GLEW_SRC_FILES ${GLEW_DIR}/build/glew.rc)
endif () endif ()
add_library (glew SHARED ${GLEW_SRC_FILES}) add_library (glew SHARED ${GLEW_PUBLIC_HEADERS_FILES} ${GLEW_SRC_FILES})
set_target_properties (glew PROPERTIES COMPILE_DEFINITIONS "GLEW_BUILD" OUTPUT_NAME "${GLEW_LIB_NAME}" PREFIX "${DLL_PREFIX}") set_target_properties (glew PROPERTIES COMPILE_DEFINITIONS "GLEW_BUILD" OUTPUT_NAME "${GLEW_LIB_NAME}" PREFIX "${DLL_PREFIX}")
add_library (glew_s STATIC ${GLEW_SRC_FILES}) add_library (glew_s STATIC ${GLEW_PUBLIC_HEADERS_FILES} ${GLEW_SRC_FILES})
set_target_properties (glew_s PROPERTIES COMPILE_DEFINITIONS "GLEW_STATIC" OUTPUT_NAME "${GLEW_LIB_NAME}" PREFIX lib) set_target_properties (glew_s PROPERTIES COMPILE_DEFINITIONS "GLEW_STATIC" OUTPUT_NAME "${GLEW_LIB_NAME}" PREFIX lib)
if (MSVC) if (MSVC)
# add options from visual studio project # add options from visual studio project
target_compile_definitions (glew PRIVATE "GLEW_BUILD;VC_EXTRALEAN") target_compile_definitions (glew PRIVATE "GLEW_BUILD;VC_EXTRALEAN")
@ -101,6 +106,20 @@ elseif (WIN32 AND ((CMAKE_C_COMPILER_ID MATCHES "GNU") OR (CMAKE_C_COMPILER_ID M
target_compile_options (glew_s PRIVATE -fno-builtin -fno-stack-protector) target_compile_options (glew_s PRIVATE -fno-builtin -fno-stack-protector)
target_link_libraries (glew LINK_PRIVATE -nostdlib) target_link_libraries (glew LINK_PRIVATE -nostdlib)
endif () endif ()
if (BUILD_FRAMEWORK)
set_target_properties(glew PROPERTIES
FRAMEWORK TRUE
FRAMEWORK_VERSION ${GLEW_VERSION}
MACOSX_FRAMEWORK_IDENTIFIER net.sourceforge.glew
MACOSX_FRAMEWORK_SHORT_VERSION_STRING ${GLEW_VERSION}
MACOSX_FRAMEWORK_BUNDLE_VERSION ${GLEW_VERSION}
XCODE_ATTRIBUTE_INSTALL_PATH "@rpath"
PUBLIC_HEADER "${GLEW_PUBLIC_HEADERS_FILES}"
OUTPUT_NAME GLEW
)
endif()
target_link_libraries (glew LINK_PUBLIC ${GLEW_LIBRARIES}) target_link_libraries (glew LINK_PUBLIC ${GLEW_LIBRARIES})
target_link_libraries (glew_s ${GLEW_LIBRARIES}) target_link_libraries (glew_s ${GLEW_LIBRARIES})
@ -128,6 +147,7 @@ install ( TARGETS ${targets_to_install}
RUNTIME DESTINATION bin RUNTIME DESTINATION bin
LIBRARY DESTINATION lib${LIB_SUFFIX} LIBRARY DESTINATION lib${LIB_SUFFIX}
ARCHIVE DESTINATION lib${LIB_SUFFIX} ARCHIVE DESTINATION lib${LIB_SUFFIX}
FRAMEWORK DESTINATION lib${LIB_SUFFIX}
) )
if (BUILD_UTILS) if (BUILD_UTILS)