Refactor build of both types of linkage 1518/head
authorKai Pastor <dg0yt@darc.de>
Thu, 29 Feb 2024 07:20:07 +0000 (08:20 +0100)
committerKai Pastor <dg0yt@darc.de>
Thu, 29 Feb 2024 07:20:07 +0000 (08:20 +0100)
src/lib/openjp2/CMakeLists.txt

index 915a22982f0380c209d4fe2378043fdccec1d199..fd62335f520cd3f285318e6b5951c9a95f73ee80 100644 (file)
@@ -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 $<INSTALL_INTERFACE:${CMAKE_INSTALL_INCLUDEDIR}/${OPENJPEG_INSTALL_SUBDIR}>)
-  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 $<INSTALL_INTERFACE:${CMAKE_INSTALL_INCLUDEDIR}/${OPENJPEG_INSTALL_SUBDIR}>)
 endif()
 
 target_include_directories(${OPENJPEG_LIBRARY_NAME} PUBLIC $<INSTALL_INTERFACE:${CMAKE_INSTALL_INCLUDEDIR}/${OPENJPEG_INSTALL_SUBDIR}>)