From eaca63aea72ed4db055514dfec2abc71a106aa70 Mon Sep 17 00:00:00 2001 From: Nigel Stewart Date: Sun, 13 Nov 2016 16:04:00 +1000 Subject: [PATCH] Mac OSX needs to link OpenGL framework for libglui.dylib --- CMakeLists.txt | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/CMakeLists.txt b/CMakeLists.txt index 033cfd6..3b3aa2b 100644 --- CMakeLists.txt +++ CMakeLists.txt @@ -49,7 +49,7 @@ add_library(glui_obj OBJECT ${GLUI_SRCS}) set_property(TARGET glui_obj PROPERTY POSITION_INDEPENDENT_CODE 1) add_library(glui SHARED $) -target_link_libraries(glui ${GLUT_LIBRARIES}) +target_link_libraries(glui ${GLUT_LIBRARIES} ${OPENGL_LIBRARIES}) add_library(glui_static STATIC $) target_link_libraries(glui_static ${GLUT_LIBRARIES}) From 4299e8fa43bb1e67370be36cad4b21115ab88af9 Mon Sep 17 00:00:00 2001 From: Simone Gasparini Date: Sun, 14 May 2017 21:44:52 +0200 Subject: [PATCH] [cmake] added install targets --- CMakeLists.txt | 96 +++++++++++++++++++++++++++++++++++++++---- cmake/Config.cmake.in | 4 ++ 2 files changed, 93 insertions(+), 7 deletions(-) create mode 100644 cmake/Config.cmake.in diff --git a/CMakeLists.txt b/CMakeLists.txt index 3b3aa2b..a73e83a 100644 --- CMakeLists.txt +++ CMakeLists.txt @@ -1,13 +1,11 @@ -cmake_minimum_required(VERSION 2.8) +cmake_minimum_required(VERSION 2.8.12) project(glui) +set(PROJECT_VERSION 2.37) find_package(GLUT REQUIRED) find_package(OpenGL REQUIRED) -include_directories(${GLUT_INCLUDE_DIR}/include) -include_directories(${CMAKE_SOURCE_DIR}/include) - SET(GLUI_SRCS algebra3.cpp arcball.cpp @@ -44,15 +42,37 @@ SET(GLUI_SRCS viewmodel.cpp ) add_library(glui_obj OBJECT ${GLUI_SRCS}) +target_include_directories(glui_obj + PUBLIC + "$" + ${OPENGL_INCLUDE_DIR} + ${GLUT_INCLUDE_DIR}) # we need to enable -fPIC this so that the same object code can be used to # create static *and* shared libraries without double compilation -set_property(TARGET glui_obj PROPERTY POSITION_INDEPENDENT_CODE 1) +set_target_properties( glui_obj PROPERTIES POSITION_INDEPENDENT_CODE 1) add_library(glui SHARED $) -target_link_libraries(glui ${GLUT_LIBRARIES} ${OPENGL_LIBRARIES}) +target_include_directories(glui + PUBLIC + "$" + "$" + ${OPENGL_INCLUDE_DIR} + ${GLUT_INCLUDE_DIR}) +target_link_libraries(glui PUBLIC ${GLUT_LIBRARIES} ${OPENGL_LIBRARIES}) +set_target_properties(glui PROPERTIES + DEBUG_POSTFIX "d" + VERSION ${PROJECT_VERSION} + SOVERSION ${PROJECT_VERSION}) add_library(glui_static STATIC $) -target_link_libraries(glui_static ${GLUT_LIBRARIES}) +target_include_directories(glui_static + PUBLIC + "$" + "$" + ${OPENGL_INCLUDE_DIR} + ${GLUT_INCLUDE_DIR}) +target_link_libraries(glui_static PUBLIC ${GLUT_LIBRARIES} ${OPENGL_LIBRARIES}) +set_target_properties(glui_static PROPERTIES DEBUG_POSTFIX "d") add_executable(ppm2array tools/ppm.cpp tools/ppm2array.cpp) target_link_libraries(ppm2array) @@ -69,3 +89,65 @@ add_executable(example5 example/example5.cpp) target_link_libraries(example5 glui_static ${GLUT_LIBRARIES} ${OPENGL_LIBRARIES}) add_executable(example6 example/example6.cpp) target_link_libraries(example6 glui_static ${GLUT_LIBRARIES} ${OPENGL_LIBRARIES}) + + + +#### +# Installation + +set(config_install_dir "lib/cmake/${PROJECT_NAME}") +set(include_install_dir "include") + +set(generated_dir "${CMAKE_CURRENT_BINARY_DIR}/generated") + +# Configuration +set(version_config "${generated_dir}/${PROJECT_NAME}ConfigVersion.cmake") +set(project_config "${generated_dir}/${PROJECT_NAME}Config.cmake") +set(targets_export_name "${PROJECT_NAME}Targets") +set(namespace "${PROJECT_NAME}::") + +# Include module with fuction 'write_basic_package_version_file' +include(CMakePackageConfigHelpers) + +# Configure 'ConfigVersion.cmake' +write_basic_package_version_file( + "${version_config}" VERSION ${PROJECT_VERSION} COMPATIBILITY SameMajorVersion +) + +# Configure 'Config.cmake' +configure_package_config_file( + "cmake/Config.cmake.in" + "${project_config}" + INSTALL_DESTINATION "${config_install_dir}" +) + +# Targets: +install( + TARGETS glui_static glui + EXPORT "${targets_export_name}" + LIBRARY DESTINATION "lib" + ARCHIVE DESTINATION "lib" + RUNTIME DESTINATION "bin" + INCLUDES DESTINATION "${include_install_dir}" +) + +# Headers: +install( + DIRECTORY "${CMAKE_SOURCE_DIR}/include/" + DESTINATION "${include_install_dir}" + FILES_MATCHING PATTERN "*.h" +) + + +# Config +install( + FILES "${project_config}" "${version_config}" + DESTINATION "${config_install_dir}" +) + +# Config +install( + EXPORT "${targets_export_name}" + NAMESPACE "${namespace}" + DESTINATION "${config_install_dir}" +) diff --git a/cmake/Config.cmake.in b/cmake/Config.cmake.in new file mode 100644 index 0000000..9b4c9ee --- /dev/null +++ cmake/Config.cmake.in @@ -0,0 +1,4 @@ +@PACKAGE_INIT@ + +include("${CMAKE_CURRENT_LIST_DIR}/@targets_export_name@.cmake") +check_required_components("@PROJECT_NAME@") --- CMakeLists.txt.orig 2018-08-27 05:43:30.000000000 -0700 +++ CMakeLists.txt 2018-08-27 05:57:15.000000000 -0700 @@ -76,20 +76,26 @@ add_executable(ppm2array tools/ppm.cpp tools/ppm2array.cpp) target_link_libraries(ppm2array) +install(TARGETS ppm2array DESTINATION bin) add_executable(example1 example/example1.cpp) target_link_libraries(example1 glui_static ${GLUT_LIBRARIES} ${OPENGL_LIBRARIES}) +install(TARGETS example1 DESTINATION share/examples/glui) add_executable(example2 example/example2.cpp) target_link_libraries(example2 glui_static ${GLUT_LIBRARIES} ${OPENGL_LIBRARIES}) +install(TARGETS example2 DESTINATION share/examples/glui) add_executable(example3 example/example3.cpp) target_link_libraries(example3 glui_static ${GLUT_LIBRARIES} ${OPENGL_LIBRARIES}) +install(TARGETS example3 DESTINATION share/examples/glui) add_executable(example4 example/example4.cpp) target_link_libraries(example4 glui_static ${GLUT_LIBRARIES} ${OPENGL_LIBRARIES}) +install(TARGETS example4 DESTINATION share/examples/glui) add_executable(example5 example/example5.cpp) target_link_libraries(example5 glui_static ${GLUT_LIBRARIES} ${OPENGL_LIBRARIES}) +install(TARGETS example5 DESTINATION share/examples/glui) add_executable(example6 example/example6.cpp) target_link_libraries(example6 glui_static ${GLUT_LIBRARIES} ${OPENGL_LIBRARIES}) - +install(TARGETS example6 DESTINATION share/examples/glui) ####