mirror of
https://github.com/nigels-com/glew.git
synced 2024-11-11 08:43:49 +00:00
cmake: allow calling find_package(GLEW) multiple times
This commit is contained in:
parent
c8c0c1e480
commit
66c5229ec2
@ -40,7 +40,21 @@ endif()
|
||||
foreach(_glew_target glew glewmx)
|
||||
set(_glew_src_target "GLEW::${_glew_target}${_glew_target_postfix}")
|
||||
string(TOUPPER "GLEW::${_glew_target}" _glew_dest_target)
|
||||
add_library(${_glew_dest_target} ${_glew_target_type} IMPORTED)
|
||||
# message(STATUS "add_library(${_glew_dest_target} ${_glew_target_type} IMPORTED)")
|
||||
copy_imported_target_properties(${_glew_src_target} ${_glew_dest_target})
|
||||
if(TARGET ${_glew_dest_target})
|
||||
get_target_property(_glew_previous_src_target ${_glew_dest_target}
|
||||
_GLEW_SRC_TARGET)
|
||||
if(NOT _glew_previous_src_target STREQUAL _glew_src_target)
|
||||
message(FATAL_ERROR "find_package(GLEW) was called the second time with "
|
||||
"different GLEW_USE_STATIC_LIBS setting. Previously, "
|
||||
"`glew-config.cmake` created ${_glew_dest_target} as a copy of "
|
||||
"${_glew_previous_src_target}. Now it attempted to copy it from "
|
||||
"${_glew_src_target}. ")
|
||||
endif()
|
||||
else()
|
||||
add_library(${_glew_dest_target} ${_glew_target_type} IMPORTED)
|
||||
# message(STATUS "add_library(${_glew_dest_target} ${_glew_target_type} IMPORTED)")
|
||||
copy_imported_target_properties(${_glew_src_target} ${_glew_dest_target})
|
||||
set_target_properties(${_glew_dest_target} PROPERTIES
|
||||
_GLEW_SRC_TARGET ${_glew_src_target})
|
||||
endif()
|
||||
endforeach()
|
||||
|
@ -2,6 +2,7 @@ cmake_minimum_required(VERSION 2.8.12)
|
||||
project(glew-cmake-test)
|
||||
|
||||
find_package(GLEW REQUIRED CONFIG)
|
||||
find_package(GLEW REQUIRED CONFIG) # call twice to test multiple call
|
||||
find_package(OpenGL REQUIRED)
|
||||
|
||||
add_executable(cmake-test main.c)
|
||||
|
Loading…
Reference in New Issue
Block a user