mirror of
https://github.com/Perlmint/glew-cmake.git
synced 2024-11-11 17:43:47 +00:00
d2e6823451
Installs a config module if CMake verion >= 2.8.12. The config-module creates the import library targets built in the project (glew, glew_s, glewmx, glewmx_s) but in accordance with the FindGLEW module shipped with CMake, it also creates GLEW::GLEW and GLEW::GLEWMX. GLEW::GLEW and GLEW::GLEWMX will be simply copies of glew/glewmx or glew_s/glewmx_s. If both versions are available they alias the shared versions. The default behaviour can be changed either when installing or when using the package: - Set BUILD_SHARED_LIBS to OFF or ON when building and installing GLEW. This controls which libraries (shared or static) will be installed (and not which will be built). - Set GLEW_USE_STATIC_LIBS to OFF or ON before calling `find_package(GLEW CONFIG REQUIRED)` to force the config-module to create GLEW::GLEW and GLEWMX as aliases to glew/glewmx or glew_s/glewmx_s The script ./cmake-testbuild.sh is added to test the CMake build and config-module. See instructions there.
25 lines
749 B
CMake
25 lines
749 B
CMake
cmake_minimum_required(VERSION 2.8.12)
|
|
project(glew-cmake-test)
|
|
|
|
find_package(GLEW REQUIRED CONFIG)
|
|
find_package(OpenGL REQUIRED)
|
|
|
|
add_executable(cmake-test main.c)
|
|
set_target_properties(cmake-test PROPERTIES DEBUG_POSTFIX _d)
|
|
target_link_libraries(cmake-test PRIVATE GLEW::GLEW ${OPENGL_LIBRARIES})
|
|
target_include_directories(cmake-test PRIVATE ${OPENGL_INCLUDE_DIR})
|
|
|
|
if(CMAKE_VERSION VERSION_LESS 3.0)
|
|
set(cgex $<CONFIG>)
|
|
else()
|
|
set(cgex $<CONFIGURATION>)
|
|
endif()
|
|
|
|
target_compile_definitions(cmake-test PRIVATE
|
|
-DGLEW_CMAKE_TEST_CONFIG=${cgex}
|
|
-DGLEW_CMAKE_TEST_TARGET_FILE_NAME=$<TARGET_FILE_NAME:GLEW::GLEW>
|
|
-DGLEW_CMAKE_TEST_TARGET_TYPE=$<TARGET_PROPERTY:GLEW::GLEW,TYPE>
|
|
)
|
|
|
|
install(TARGETS cmake-test DESTINATION bin)
|