revert to previous behaviour for cmake: builds (and links) dynamically by default. Static build only if -DBUILD_SHARED_LIBS is set to OFF.

This commit is contained in:
Antonin Descampe 2010-12-05 15:19:57 +00:00
parent cf39198a9a
commit 59d9b97ffe
9 changed files with 53 additions and 135 deletions

View File

@ -6,6 +6,7 @@ What's New for OpenJPEG
+ : added
December 5, 2010
! [antonin] revert to previous behaviour for cmake: builds (and links) dynamically by default. Static build only if -DBUILD_SHARED_LIBS is set to OFF.
* [antonin] added a definition in getopt.h and an initial value in convert.c
December 3, 2010

View File

@ -126,7 +126,7 @@ CONFIGURE_FILE(
#-----------------------------------------------------------------------------
# OpenJPEG build configuration options.
OPTION(BUILD_SHARED_LIBS "Build OpenJPEG shared libraries." ON)
OPTION(BUILD_SHARED_LIBS "Build OpenJPEG shared library and link executables against it." ON)
#-----------------------------------------------------------------------------
SET (EXECUTABLE_OUTPUT_PATH ${OPENJPEG_BINARY_DIR}/bin CACHE PATH "Single output directory for building all executables.")
@ -149,36 +149,36 @@ INCLUDE_DIRECTORIES(BEFORE ${CMAKE_CURRENT_BINARY_DIR})
SUBDIRS(libopenjpeg)
#-----------------------------------------------------------------------------
# Build CODEC binaries ?
OPTION(BUILD_CODEC "Build the CODEC binaries" ON)
# Build CODEC executables ?
OPTION(BUILD_CODEC "Build the CODEC executables" ON)
IF(BUILD_CODEC)
SUBDIRS(codec)
ENDIF(BUILD_CODEC)
#-----------------------------------------------------------------------------
# Build MJ2 binaries ?
OPTION(BUILD_MJ2 "Build the MJ2 binaries." OFF)
# Build MJ2 executables ?
OPTION(BUILD_MJ2 "Build the MJ2 executables." OFF)
IF(BUILD_MJ2)
SUBDIRS(mj2)
ENDIF(BUILD_MJ2)
#-----------------------------------------------------------------------------
# Build JPWL binaries ?
OPTION(BUILD_JPWL "Build the JPWL binaries" OFF)
# Build JPWL executables ?
OPTION(BUILD_JPWL "Build the JPWL executables" OFF)
IF(BUILD_JPWL)
SUBDIRS(jpwl)
ENDIF(BUILD_JPWL)
#-----------------------------------------------------------------------------
# Build JP3D binaries ?
OPTION(BUILD_JP3D "Build the JP3D binaries" OFF)
# Build JP3D executables ?
OPTION(BUILD_JP3D "Build the JP3D executables" OFF)
IF(BUILD_JP3D)
SUBDIRS(jp3d)
ENDIF(BUILD_JP3D)
#-----------------------------------------------------------------------------
# Build INDEXER_JPIP binaries ?
OPTION(BUILD_INDEXER_JPIP "Build the INDEXER_JPIP binaries" OFF)
# Build INDEXER_JPIP executables ?
OPTION(BUILD_INDEXER_JPIP "Build the INDEXER_JPIP executables" OFF)
IF(BUILD_INDEXER_JPIP AND NOT UNIX)
SUBDIRS(indexer_JPIP)
ENDIF(BUILD_INDEXER_JPIP AND NOT UNIX)

View File

@ -51,12 +51,11 @@ else:
make clean
Binaries are located in the 'bin' directory.
Executables are always statically linked.
Main available cmake flags:
* To specify the install path: '-DCMAKE_INSTALL_PREFIX=/path'
* To build the shared libraries: '-DBUILD_SHARED_LIBS:bool=on' (default: 'ON')
Note: when using this option, shared libraries are built but executables remain linked against the corresponding static libraries.
* To build the shared libraries and links the executables against it: '-DBUILD_SHARED_LIBS:bool=on' (default: 'ON')
Note: when using this option, static libraries are not built and executables are dynamically linked.
* To build the CODEC executables: '-DBUILD_CODEC:bool=on' (default: 'ON')
* To build the MJ2 executables: '-DBUILD_MJ2:bool=on' (default: 'OFF')
* To build the JPWL executables and JPWL library: '-DBUILD_JPWL:bool=on' (default: 'OFF')

View File

@ -14,10 +14,6 @@ IF(DONT_HAVE_GETOPT)
)
ENDIF(DONT_HAVE_GETOPT)
# Do the proper thing when building static...if only there was configured
# headers or def files instead
ADD_DEFINITIONS(-DOPJ_STATIC)
# Headers file are located here:
INCLUDE_DIRECTORIES(
${OPENJPEG_SOURCE_DIR}/libopenjpeg
@ -33,7 +29,7 @@ ENDIF(TIFF_FOUND)
# Loop over all executables:
FOREACH(exe j2k_to_image image_to_j2k j2k_dump)
ADD_EXECUTABLE(${exe} ${exe}.c ${common_SRCS})
TARGET_LINK_LIBRARIES(${exe} ${OPENJPEG_LIBRARY_NAME}.static ${LCMS_LIB})
TARGET_LINK_LIBRARIES(${exe} ${OPENJPEG_LIBRARY_NAME} ${LCMS_LIB})
IF(PNG_FOUND)
TARGET_LINK_LIBRARIES(${exe} ${PNG_LIBRARIES})
ENDIF(PNG_FOUND)

View File

@ -24,17 +24,10 @@ IF(DONT_HAVE_GETOPT)
)
ENDIF(DONT_HAVE_GETOPT)
# Do the proper thing when building static...if only there was configured
# headers or def files instead
ADD_DEFINITIONS(-DOPJ_STATIC)
#FIND_PACKAGE(TIFF REQUIRED)
# Loop over all executables:
FOREACH(exe jp3d_to_volume volume_to_jp3d)
ADD_EXECUTABLE(${exe} ${exe}.c ${common_SRCS})
TARGET_LINK_LIBRARIES(${exe} ${OPENJPEG_LIBRARY_NAME}_JP3D.static) # ${TIFF_LIBRARIES})
TARGET_LINK_LIBRARIES(${exe} ${OPENJPEG_LIBRARY_NAME}_JP3D) # ${TIFF_LIBRARIES})
# On unix you need to link to the math library:
IF(UNIX)
TARGET_LINK_LIBRARIES(${exe} m)

View File

@ -14,51 +14,28 @@ IF(LCMS_INCLUDE_DIR)
INCLUDE_DIRECTORIES( ${LCMS_INCLUDE_DIR} )
ENDIF(LCMS_INCLUDE_DIR)
# Build the static library
# Build the library
IF(WIN32)
ADD_DEFINITIONS(-DOPJ_STATIC)
IF(BUILD_SHARED_LIBS)
ADD_DEFINITIONS(-DOPJ_EXPORTS)
ELSE(BUILD_SHARED_LIBS)
ADD_DEFINITIONS(-DOPJ_STATIC)
ENDIF(BUILD_SHARED_LIBS)
ENDIF(WIN32)
ADD_LIBRARY(${OPENJPEG_LIBRARY_NAME}_JP3D.static STATIC ${JP3DVM_SRCS})
SET_TARGET_PROPERTIES(${OPENJPEG_LIBRARY_NAME}_JP3D.static PROPERTIES OUTPUT_NAME ${OPENJPEG_LIBRARY_NAME}_JP3D)
SET_TARGET_PROPERTIES(${OPENJPEG_LIBRARY_NAME}_JP3D.static
ADD_LIBRARY(${OPENJPEG_LIBRARY_NAME}_JP3D ${JP3DVM_SRCS})
SET_TARGET_PROPERTIES(${OPENJPEG_LIBRARY_NAME}_JP3D
PROPERTIES
VERSION 1.3.0
SOVERSION 1)
IF(LCMS_LIB)
TARGET_LINK_LIBRARIES(${OPENJPEG_LIBRARY_NAME}_JP3D.static ${LCMS_LIB})
TARGET_LINK_LIBRARIES(${OPENJPEG_LIBRARY_NAME}_JP3D ${LCMS_LIB})
ENDIF(LCMS_LIB)
# Install library
INSTALL(TARGETS ${OPENJPEG_LIBRARY_NAME}_JP3D.static
INSTALL(TARGETS ${OPENJPEG_LIBRARY_NAME}_JP3D
DESTINATION ${OPENJPEG_INSTALL_LIB_DIR} COMPONENT Libraries
)
# If BUILD_SHARED_LIBS is ON, also build the shared library
IF(BUILD_SHARED_LIBS)
# replace flag for static build with flag for shared build
IF(WIN32)
REMOVE_DEFINITIONS(-DOPJ_STATIC)
ADD_DEFINITIONS(-DOPJ_EXPORTS)
ENDIF(WIN32)
# Create the shared library
ADD_LIBRARY(${OPENJPEG_LIBRARY_NAME}_JP3D.shared SHARED ${JP3DVM_SRCS})
SET_TARGET_PROPERTIES(${OPENJPEG_LIBRARY_NAME}_JP3D.shared PROPERTIES OUTPUT_NAME ${OPENJPEG_LIBRARY_NAME}_JP3D)
SET_TARGET_PROPERTIES(${OPENJPEG_LIBRARY_NAME}_JP3D.shared
PROPERTIES
VERSION 1.3.0
SOVERSION 1)
IF(LCMS_LIB)
TARGET_LINK_LIBRARIES(${OPENJPEG_LIBRARY_NAME}_JP3D.shared ${LCMS_LIB})
ENDIF(LCMS_LIB)
# Install library
INSTALL(TARGETS ${OPENJPEG_LIBRARY_NAME}_JP3D.shared
DESTINATION ${OPENJPEG_INSTALL_LIB_DIR} COMPONENT Libraries
)
IF(WIN32)
REMOVE_DEFINITIONS(-DOPJ_EXPORTS)
ENDIF(WIN32)
ENDIF(BUILD_SHARED_LIBS)
# Install includes files
INSTALL(FILES openjpeg.h
DESTINATION ${OPENJPEG_INSTALL_INCLUDE_DIR}/openjpeg3d-1.3

View File

@ -37,48 +37,24 @@ IF(LCMS_INCLUDE_DIR)
INCLUDE_DIRECTORIES( ${LCMS_INCLUDE_DIR} )
ENDIF(LCMS_INCLUDE_DIR)
# Build the static library
# Build the library
IF(WIN32)
ADD_DEFINITIONS(-DOPJ_STATIC)
IF(BUILD_SHARED_LIBS)
ADD_DEFINITIONS(-DOPJ_EXPORTS)
ELSE(BUILD_SHARED_LIBS)
ADD_DEFINITIONS(-DOPJ_STATIC)
ENDIF(BUILD_SHARED_LIBS)
ENDIF(WIN32)
ADD_LIBRARY(${OPENJPEG_LIBRARY_NAME}_JPWL.static STATIC ${JPWL_SRCS} ${OPJ_SRCS})
SET_TARGET_PROPERTIES(${OPENJPEG_LIBRARY_NAME}_JPWL.static PROPERTIES OUTPUT_NAME ${OPENJPEG_LIBRARY_NAME}_JPWL)
SET_TARGET_PROPERTIES(${OPENJPEG_LIBRARY_NAME}_JPWL.static PROPERTIES ${OPENJPEG_LIBRARY_PROPERTIES})
ADD_LIBRARY(${OPENJPEG_LIBRARY_NAME}_JPWL ${JPWL_SRCS} ${OPJ_SRCS})
SET_TARGET_PROPERTIES(${OPENJPEG_LIBRARY_NAME}_JPWL PROPERTIES ${OPENJPEG_LIBRARY_PROPERTIES})
IF(LCMS_LIB)
TARGET_LINK_LIBRARIES(${OPENJPEG_LIBRARY_NAME}_JPWL.static ${LCMS_LIB})
TARGET_LINK_LIBRARIES(${OPENJPEG_LIBRARY_NAME}_JPWL ${LCMS_LIB})
ENDIF(LCMS_LIB)
# Install library
INSTALL(TARGETS ${OPENJPEG_LIBRARY_NAME}_JPWL.static
INSTALL(TARGETS ${OPENJPEG_LIBRARY_NAME}_JPWL
DESTINATION ${OPENJPEG_INSTALL_LIB_DIR} COMPONENT Libraries
)
# If BUILD_SHARED_LIBS is ON, also build the shared library
IF(BUILD_SHARED_LIBS)
# replace flag for static build with flag for shared build
IF(WIN32)
REMOVE_DEFINITIONS(-DOPJ_STATIC)
ADD_DEFINITIONS(-DOPJ_EXPORTS)
ENDIF(WIN32)
# Create the shared library
ADD_LIBRARY(${OPENJPEG_LIBRARY_NAME}_JPWL.shared SHARED ${JPWL_SRCS} ${OPJ_SRCS})
SET_TARGET_PROPERTIES(${OPENJPEG_LIBRARY_NAME}_JPWL.shared PROPERTIES OUTPUT_NAME ${OPENJPEG_LIBRARY_NAME}_JPWL)
SET_TARGET_PROPERTIES(${OPENJPEG_LIBRARY_NAME}_JPWL.shared PROPERTIES ${OPENJPEG_LIBRARY_PROPERTIES})
IF(LCMS_LIB)
TARGET_LINK_LIBRARIES(${OPENJPEG_LIBRARY_NAME}_JPWL.shared ${LCMS_LIB})
ENDIF(LCMS_LIB)
# Install library
INSTALL(TARGETS ${OPENJPEG_LIBRARY_NAME}_JPWL.shared
DESTINATION ${OPENJPEG_INSTALL_LIB_DIR} COMPONENT Libraries
)
IF(WIN32)
REMOVE_DEFINITIONS(-DOPJ_EXPORTS)
ENDIF(WIN32)
ENDIF(BUILD_SHARED_LIBS)
# Do the proper thing when building static...if only there was configured
# headers or def files instead
ADD_DEFINITIONS(-DOPJ_STATIC)
INCLUDE_DIRECTORIES(
${OPENJPEG_SOURCE_DIR}/libopenjpeg
${LCMS_INCLUDE_DIR}
@ -96,7 +72,7 @@ ADD_EXECUTABLE(JPWL_j2k_to_image
../codec/index.c
../codec/j2k_to_image.c
)
TARGET_LINK_LIBRARIES(JPWL_j2k_to_image ${OPENJPEG_LIBRARY_NAME}_JPWL.static ${LCMS_LIB})
TARGET_LINK_LIBRARIES(JPWL_j2k_to_image ${OPENJPEG_LIBRARY_NAME}_JPWL ${LCMS_LIB})
IF(PNG_FOUND)
TARGET_LINK_LIBRARIES(JPWL_j2k_to_image ${PNG_LIBRARIES})
ENDIF(PNG_FOUND)
@ -113,7 +89,7 @@ ADD_EXECUTABLE(JPWL_image_to_j2k
../codec/index.c
../codec/image_to_j2k.c
)
TARGET_LINK_LIBRARIES(JPWL_image_to_j2k ${OPENJPEG_LIBRARY_NAME}_JPWL.static ${LCMS_LIB})
TARGET_LINK_LIBRARIES(JPWL_image_to_j2k ${OPENJPEG_LIBRARY_NAME}_JPWL ${LCMS_LIB})
IF(PNG_FOUND)
TARGET_LINK_LIBRARIES(JPWL_image_to_j2k ${PNG_LIBRARIES})
ENDIF(PNG_FOUND)

View File

@ -26,46 +26,26 @@ IF(LCMS_INCLUDE_DIR)
INCLUDE_DIRECTORIES( ${LCMS_INCLUDE_DIR} )
ENDIF(LCMS_INCLUDE_DIR)
# Build the static library
# Build the library
IF(WIN32)
ADD_DEFINITIONS(-DOPJ_STATIC)
IF(BUILD_SHARED_LIBS)
ADD_DEFINITIONS(-DOPJ_EXPORTS)
ELSE(BUILD_SHARED_LIBS)
ADD_DEFINITIONS(-DOPJ_STATIC)
ENDIF(BUILD_SHARED_LIBS)
ENDIF(WIN32)
ADD_LIBRARY(${OPENJPEG_LIBRARY_NAME}.static STATIC ${OPENJPEG_SRCS})
SET_TARGET_PROPERTIES(${OPENJPEG_LIBRARY_NAME}.static PROPERTIES CLEAN_DIRECT_OUTPUT 1 OUTPUT_NAME ${OPENJPEG_LIBRARY_NAME} PREFIX "lib")
SET_TARGET_PROPERTIES(${OPENJPEG_LIBRARY_NAME}.static PROPERTIES ${OPENJPEG_LIBRARY_PROPERTIES})
ADD_LIBRARY(${OPENJPEG_LIBRARY_NAME} ${OPENJPEG_SRCS})
SET_TARGET_PROPERTIES(${OPENJPEG_LIBRARY_NAME} PROPERTIES ${OPENJPEG_LIBRARY_PROPERTIES})
IF(LCMS_LIB)
TARGET_LINK_LIBRARIES(${OPENJPEG_LIBRARY_NAME}.static ${LCMS_LIB})
TARGET_LINK_LIBRARIES(${OPENJPEG_LIBRARY_NAME} ${LCMS_LIB})
ENDIF(LCMS_LIB)
# Install library
INSTALL(TARGETS ${OPENJPEG_LIBRARY_NAME}.static
INSTALL(TARGETS ${OPENJPEG_LIBRARY_NAME}
EXPORT OpenJPEGTargets
DESTINATION ${OPENJPEG_INSTALL_LIB_DIR} COMPONENT Libraries
)
# If BUILD_SHARED_LIBS is ON, also build the shared library
IF(BUILD_SHARED_LIBS)
# replace flag for static build with flag for shared build
IF(WIN32)
REMOVE_DEFINITIONS(-DOPJ_STATIC)
ADD_DEFINITIONS(-DOPJ_EXPORTS)
ENDIF(WIN32)
# Create the shared library
ADD_LIBRARY(${OPENJPEG_LIBRARY_NAME}.shared SHARED ${OPENJPEG_SRCS})
SET_TARGET_PROPERTIES(${OPENJPEG_LIBRARY_NAME}.shared PROPERTIES OUTPUT_NAME ${OPENJPEG_LIBRARY_NAME})
SET_TARGET_PROPERTIES(${OPENJPEG_LIBRARY_NAME}.shared PROPERTIES ${OPENJPEG_LIBRARY_PROPERTIES})
IF(LCMS_LIB)
TARGET_LINK_LIBRARIES(${OPENJPEG_LIBRARY_NAME}.shared ${LCMS_LIB})
ENDIF(LCMS_LIB)
# Install library
INSTALL(TARGETS ${OPENJPEG_LIBRARY_NAME}.shared
EXPORT OpenJPEGTargets
DESTINATION ${OPENJPEG_INSTALL_LIB_DIR} COMPONENT Libraries
)
IF(WIN32)
REMOVE_DEFINITIONS(-DOPJ_EXPORTS)
ENDIF(WIN32)
ENDIF(BUILD_SHARED_LIBS)
# Install includes files
INSTALL(FILES openjpeg.h
DESTINATION ${OPENJPEG_INSTALL_INCLUDE_DIR}/${subdir} COMPONENT Headers

View File

@ -7,17 +7,13 @@ INCLUDE_DIRECTORIES(
${LCMS_INCLUDE_DIR}
)
# Do the proper thing when building static...if only there was configured
# headers or def files instead
ADD_DEFINITIONS(-DOPJ_STATIC)
ADD_EXECUTABLE(frames_to_mj2
frames_to_mj2.c
${PROJECT_SOURCE_DIR}/codec/compat/getopt.c
mj2_convert.c
mj2.c
)
TARGET_LINK_LIBRARIES(frames_to_mj2 ${OPENJPEG_LIBRARY_NAME}.static ${LCMS_LIB})
TARGET_LINK_LIBRARIES(frames_to_mj2 ${OPENJPEG_LIBRARY_NAME} ${LCMS_LIB})
IF(UNIX)
TARGET_LINK_LIBRARIES(frames_to_mj2 m)
ENDIF(UNIX)
@ -28,7 +24,7 @@ ADD_EXECUTABLE(mj2_to_frames
mj2_convert.c
mj2.c
)
TARGET_LINK_LIBRARIES(mj2_to_frames ${OPENJPEG_LIBRARY_NAME}.static ${LCMS_LIB})
TARGET_LINK_LIBRARIES(mj2_to_frames ${OPENJPEG_LIBRARY_NAME} ${LCMS_LIB})
IF(UNIX)
TARGET_LINK_LIBRARIES(mj2_to_frames m)
ENDIF(UNIX)
@ -36,7 +32,7 @@ ENDIF(UNIX)
ADD_EXECUTABLE(extract_j2k_from_mj2
extract_j2k_from_mj2.c
mj2.c )
TARGET_LINK_LIBRARIES(extract_j2k_from_mj2 ${OPENJPEG_LIBRARY_NAME}.static ${LCMS_LIB})
TARGET_LINK_LIBRARIES(extract_j2k_from_mj2 ${OPENJPEG_LIBRARY_NAME} ${LCMS_LIB})
IF(UNIX)
TARGET_LINK_LIBRARIES(extract_j2k_from_mj2 m)
ENDIF(UNIX)
@ -44,7 +40,7 @@ ENDIF(UNIX)
ADD_EXECUTABLE(wrap_j2k_in_mj2
wrap_j2k_in_mj2.c
mj2.c )
TARGET_LINK_LIBRARIES(wrap_j2k_in_mj2 ${OPENJPEG_LIBRARY_NAME}.static ${LCMS_LIB})
TARGET_LINK_LIBRARIES(wrap_j2k_in_mj2 ${OPENJPEG_LIBRARY_NAME} ${LCMS_LIB})
IF(UNIX)
TARGET_LINK_LIBRARIES(wrap_j2k_in_mj2 m)
ENDIF(UNIX)