Skip to content

Commit

Permalink
assimpTargets.cmake: define add_library() with lib type directly
Browse files Browse the repository at this point in the history
Instead of using if(ON)/if(OFF) to determine which of the "hardcoded"
add_library(... SHARED ...)  or (... STATIC ...) should be used,
specify a new BUILD_LIB_TYPE variable that is set directly to either
SHARED or STATIC and substituted in the `add_library()` statement
when assimpTargets.cmake.in is configured.

This removes a CMP0012 collision with prior `cmake_policy(VERSION 2.6)`
statement and makes the CMP0012 warning not appear in users' projects.
This problem is mentioned in issue #2685.
  • Loading branch information
Zalewa committed Oct 6, 2019
1 parent 0761530 commit 6ac8279
Show file tree
Hide file tree
Showing 2 changed files with 6 additions and 5 deletions.
5 changes: 5 additions & 0 deletions CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -391,6 +391,11 @@ IF(HUNTER_ENABLED)
)
ELSE(HUNTER_ENABLED)
# cmake configuration files
if(${BUILD_SHARED_LIBS})
set(BUILD_LIB_TYPE SHARED)
else()
set(BUILD_LIB_TYPE STATIC)
endif()
CONFIGURE_FILE("${CMAKE_CURRENT_SOURCE_DIR}/assimp-config.cmake.in" "${CMAKE_CURRENT_BINARY_DIR}/assimp-config.cmake" @ONLY IMMEDIATE)
CONFIGURE_FILE("${CMAKE_CURRENT_SOURCE_DIR}/assimpTargets.cmake.in" "${CMAKE_CURRENT_BINARY_DIR}/assimpTargets.cmake" @ONLY IMMEDIATE)
IF (is_multi_config)
Expand Down
6 changes: 1 addition & 5 deletions assimpTargets.cmake.in
Original file line number Diff line number Diff line change
Expand Up @@ -51,11 +51,7 @@ if(_IMPORT_PREFIX STREQUAL "/")
endif()

# Create imported target assimp::assimp
if(@BUILD_SHARED_LIBS@)
add_library(assimp::assimp SHARED IMPORTED)
else()
add_library(assimp::assimp STATIC IMPORTED)
endif()
add_library(assimp::assimp @BUILD_LIB_TYPE@ IMPORTED)

set_target_properties(assimp::assimp PROPERTIES
COMPATIBLE_INTERFACE_STRING "assimp_MAJOR_VERSION"
Expand Down

0 comments on commit 6ac8279

Please sign in to comment.