Skip to content

Commit

Permalink
Refactor build of both types of linkage
Browse files Browse the repository at this point in the history
  • Loading branch information
dg0yt authored and rouault committed Mar 4, 2024
1 parent 4b8b397 commit c28f012
Showing 1 changed file with 8 additions and 14 deletions.
22 changes: 8 additions & 14 deletions src/lib/openjp2/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -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}>)
Expand Down

0 comments on commit c28f012

Please sign in to comment.