From 253059c6395f1fe3e6ac7bf80b535b142c65e5ce Mon Sep 17 00:00:00 2001 From: Quim Muntal Date: Thu, 4 Feb 2021 21:13:18 +0100 Subject: [PATCH] Support building mingw static and dynamic at the same time (#677) Restrict the behavior disallowing the build of both libraries to MSVC. The mingw CMake generators handle the situation properly: - Shared library suffix: .dll - Import library suffix: .a.dll - Static library suffix: .a --- CMakeLists.txt | 2 +- cmake/draco_build_definitions.cmake | 2 +- cmake/draco_install.cmake | 2 +- cmake/draco_targets.cmake | 6 +++--- 4 files changed, 6 insertions(+), 6 deletions(-) diff --git a/CMakeLists.txt b/CMakeLists.txt index 53fa47f..5526e7f 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -804,7 +804,7 @@ else() draco_points_enc) # Library targets that consume the object collections. - if(MSVC OR WIN32) + if(MSVC) # In order to produce a DLL and import library the Windows tools require # that the exported symbols are part of the DLL target. The unfortunate side # effect of this is that a single configuration cannot output both the diff --git a/cmake/draco_build_definitions.cmake b/cmake/draco_build_definitions.cmake index c1ada62..57e9ef5 100644 --- a/cmake/draco_build_definitions.cmake +++ b/cmake/draco_build_definitions.cmake @@ -6,7 +6,7 @@ set(DRACO_CMAKE_DRACO_BUILD_DEFINITIONS_CMAKE_ 1) # Utility for controlling the main draco library dependency. This changes in # shared builds, and when an optional target requires a shared library build. macro(set_draco_target) - if(MSVC OR WIN32) + if(MSVC) set(draco_dependency draco) set(draco_plugin_dependency ${draco_dependency}) else() diff --git a/cmake/draco_install.cmake b/cmake/draco_install.cmake index 5c63ecb..09bfb59 100644 --- a/cmake/draco_install.cmake +++ b/cmake/draco_install.cmake @@ -55,7 +55,7 @@ macro(draco_setup_install_target) install(TARGETS draco_encoder DESTINATION "${CMAKE_INSTALL_PREFIX}/${CMAKE_INSTALL_BINDIR}") - if(WIN32) + if(MSVC) install(TARGETS draco DESTINATION "${CMAKE_INSTALL_PREFIX}/${CMAKE_INSTALL_LIBDIR}") else() diff --git a/cmake/draco_targets.cmake b/cmake/draco_targets.cmake index 0572a17..30f8501 100644 --- a/cmake/draco_targets.cmake +++ b/cmake/draco_targets.cmake @@ -164,8 +164,8 @@ endmacro() # cmake-format: off # - OUTPUT_NAME: Override output file basename. Target basename defaults to # NAME. OUTPUT_NAME is ignored when BUILD_SHARED_LIBS is enabled and CMake -# is generating a build for which MSVC or WIN32 are true. This is to avoid -# output basename collisions with DLL import libraries. +# is generating a build for which MSVC is true. This is to avoid output +# basename collisions with DLL import libraries. # - TEST: Flag. Presence means treat library as a test. # - DEFINES: List of preprocessor macro definitions. # - INCLUDES: list of include directories for the target. @@ -260,7 +260,7 @@ macro(draco_add_library) endif() if(lib_OUTPUT_NAME) - if(NOT (BUILD_SHARED_LIBS AND (MSVC OR WIN32))) + if(NOT (BUILD_SHARED_LIBS AND MSVC)) set_target_properties(${lib_NAME} PROPERTIES OUTPUT_NAME ${lib_OUTPUT_NAME}) endif()