[Fix #38] [Fix #41] Fix install symbolic link

This commit is contained in:
Gyusun Yeom 2021-02-08 23:34:17 +09:00
parent 5cc3b4b8a8
commit e983f5e0ee

View File

@ -115,23 +115,55 @@ endif()
set(GLEW_TARGETS) set(GLEW_TARGETS)
if(glew-cmake_BUILD_STATIC) if(NOT CMAKE_INSTALL_LIBDIR)
add_library(libglew_static STATIC ${LIBGLEW_SRCS}) set(INSTALL_LIBDIR lib)
else()
set(INSTALL_LIBDIR ${CMAKE_INSTALL_LIBDIR})
endif()
set_target_properties(libglew_static PROPERTIES function(set_representative_target TARGET)
set_target_properties(${TARGET} PROPERTIES
OUTPUT_NAME "glew" OUTPUT_NAME "glew"
DEBUG_POSTFIX d) DEBUG_POSTFIX d)
# Windows & macOS use case-insensetive FS. do not create symbolic link
if(NOT WIN32 and NOT APPLE)
get_target_property(TARGET_TYPE ${TARGET} TYPE)
if(TARGET_TYPE STREQUAL STATIC_LIBRARY)
set(EXT ".a")
get_target_property(OUT_DIR ${TARGET} ARCHIVE_OUTPUT_DIRECTORY)
else()
set(EXT ".so")
get_target_property(OUT_DIR ${TARGET} LIBRARY_OUTPUT_DIRECTORY)
endif()
if(NOT ${CMAKE_VERSION} VERSION_LESS 3.0)
add_custom_command(TARGET ${TARGET} POST_BUILD
COMMAND ${CMAKE_COMMAND} ARGS -E create_symlink libglew${EXT} libGLEW${EXT}
WORKING_DIRECTORY ${OUT_DIR}
BYPRODUCTS ${OUT_DIR}/libGLEW${EXT}
COMMENT "create libGLEW symbolic link")
else()
add_custom_command(TARGET ${TARGET} POST_BUILD
COMMAND bash ARGS -c "( test ! -e ${OUT_DIR}/libGLEW${EXT} && cd ${OUT_DIR} && ${CMAKE_COMMAND} -E create_symlink libglew${EXT} libGLEW${EXT} ) || true"
COMMENT "create libGLEW symbolic link"
VERBATIM)
endif()
if(NOT ${CMAKE_VERSION} VERSION_LESS 3.14)
install(FILES ${OUT_DIR}/libGLEW${EXT} TYPE LIB)
else()
install(FILES ${OUT_DIR}/libGLEW${EXT} DESTINATION ${INSTALL_LIBDIR})
endif()
endif()
endfunction()
if(glew-cmake_BUILD_STATIC)
add_library(libglew_static STATIC ${LIBGLEW_SRCS})
set_representative_target(libglew_static)
target_compile_definitions(libglew_static PUBLIC GLEW_STATIC) target_compile_definitions(libglew_static PUBLIC GLEW_STATIC)
list(APPEND GLEW_TARGETS libglew_static) list(APPEND GLEW_TARGETS libglew_static)
if(NOT WIN32)
add_custom_command(TARGET libglew_static POST_BUILD
COMMAND ${CMAKE_COMMAND} ARGS -E create_symlink libglew.a libGLEW.a
WORKING_DIRECTORY ${CMAKE_ARCHIVE_OUTPUT_DIRECTORY}
BYPRODUCTS ${CMAKE_ARCHIVE_OUTPUT_DIRECTORY}/libGLEW.a
COMMENT "create libGLEW symbolic link")
install(FILES ${CMAKE_ARCHIVE_OUTPUT_DIRECTORY}/libGLEW.a TYPE LIB)
endif()
endif() endif()
if(glew-cmake_BUILD_SHARED) if(glew-cmake_BUILD_SHARED)
@ -142,17 +174,7 @@ if(glew-cmake_BUILD_SHARED)
OUTPUT_NAME "glew-shared" OUTPUT_NAME "glew-shared"
DEBUG_POSTFIX d) DEBUG_POSTFIX d)
else() else()
set_target_properties(libglew_shared PROPERTIES set_representative_target(libglew_shared)
OUTPUT_NAME "glew"
DEBUG_POSTFIX d)
if(NOT WIN32)
add_custom_command(TARGET libglew_shared POST_BUILD
COMMAND ${CMAKE_COMMAND} ARGS -E create_symlink libglew.so libGLEW.so
WORKING_DIRECTORY ${CMAKE_LIBRARY_OUTPUT_DIRECTORY}
BYPRODUCTS ${CMAKE_LIBRARY_OUTPUT_DIRECTORY}/libGLEW.so
COMMENT "create libGLEW symbolic link")
install(FILES ${CMAKE_LIBRARY_OUTPUT_DIRECTORY}/libGLEW.so TYPE LIB)
endif()
endif() endif()
target_compile_definitions(libglew_shared PRIVATE GLEW_BUILD) target_compile_definitions(libglew_shared PRIVATE GLEW_BUILD)
@ -169,14 +191,14 @@ endforeach()
if(PKG_CONFIG_REPRESENTATIVE_TARGET) if(PKG_CONFIG_REPRESENTATIVE_TARGET)
GeneratePkgConfigFile(${PKG_CONFIG_REPRESENTATIVE_TARGET} "The OpenGL Extension Wrangler library" GeneratePkgConfigFile(${PKG_CONFIG_REPRESENTATIVE_TARGET} "The OpenGL Extension Wrangler library"
NAME "glew" NAME "glew"
LIBRARY_DIR lib LIBRARY_DIR ${INSTALL_LIBDIR}
REQUIRES ${pc_requires}) REQUIRES ${pc_requires})
endif() endif()
install(TARGETS ${GLEW_TARGETS} install(TARGETS ${GLEW_TARGETS} EXPORT glew-cmake
EXPORT glew-cmake ARCHIVE DESTINATION ${INSTALL_LIBDIR}
ARCHIVE DESTINATION lib) LIBRARY DESTINATION ${INSTALL_LIBDIR})
install(EXPORT glew-cmake DESTINATION lib/cmake/glew FILE glewConfig.cmake) install(EXPORT glew-cmake DESTINATION ${INSTALL_LIBDIR}/cmake/glew FILE glewConfig.cmake)
file(GLOB PUBLIC_HEADERS "include/GL/*.h") file(GLOB PUBLIC_HEADERS "include/GL/*.h")
install(FILES ${PUBLIC_HEADERS} DESTINATION include/GL/) install(FILES ${PUBLIC_HEADERS} DESTINATION include/GL/)