From 51d1cd40f716d7a0d1b77e0a77796eb86b17136a Mon Sep 17 00:00:00 2001 From: Kai Pastor Date: Thu, 29 Feb 2024 08:20:07 +0100 Subject: [PATCH] Refactor build of both types of linkage --- src/lib/openjp2/CMakeLists.txt | 22 ++++++++-------------- 1 file changed, 8 insertions(+), 14 deletions(-) diff --git a/src/lib/openjp2/CMakeLists.txt b/src/lib/openjp2/CMakeLists.txt index 915a2298..fd62335f 100644 --- a/src/lib/openjp2/CMakeLists.txt +++ b/src/lib/openjp2/CMakeLists.txt @@ -82,26 +82,20 @@ if(NOT WIN32 AND CMAKE_COMPILER_IS_GNUCC AND CMAKE_C_COMPILER MATCHES ".*mingw32 endif() # Build the library +add_library(${OPENJPEG_LIBRARY_NAME} ${OPENJPEG_SRCS}) +set(INSTALL_LIBS ${OPENJPEG_LIBRARY_NAME}) if(WIN32) - add_library(${OPENJPEG_LIBRARY_NAME} ${OPENJPEG_SRCS}) if(BUILD_SHARED_LIBS) target_compile_definitions(${OPENJPEG_LIBRARY_NAME} PRIVATE OPJ_EXPORTS) else() target_compile_definitions(${OPENJPEG_LIBRARY_NAME} PUBLIC OPJ_STATIC) endif() - set(INSTALL_LIBS ${OPENJPEG_LIBRARY_NAME}) -else() - if(BUILD_SHARED_LIBS AND BUILD_STATIC_LIBS) - # Builds both static and dynamic libs - add_library(${OPENJPEG_LIBRARY_NAME} SHARED ${OPENJPEG_SRCS}) - add_library(openjp2_static STATIC ${OPENJPEG_SRCS}) - set_target_properties(openjp2_static PROPERTIES OUTPUT_NAME ${OPENJPEG_LIBRARY_NAME}) - set(INSTALL_LIBS ${OPENJPEG_LIBRARY_NAME} openjp2_static) - target_include_directories(openjp2_static PUBLIC $) - else() - add_library(${OPENJPEG_LIBRARY_NAME} ${OPENJPEG_SRCS}) - set(INSTALL_LIBS ${OPENJPEG_LIBRARY_NAME}) - endif() +elseif(BUILD_SHARED_LIBS AND BUILD_STATIC_LIBS) + # Builds both static and dynamic libs + add_library(openjp2_static STATIC ${OPENJPEG_SRCS}) + set_target_properties(openjp2_static PROPERTIES OUTPUT_NAME ${OPENJPEG_LIBRARY_NAME}) + list(APPEND INSTALL_LIBS openjp2_static) + target_include_directories(openjp2_static PUBLIC $) endif() target_include_directories(${OPENJPEG_LIBRARY_NAME} PUBLIC $) -- 2.30.2