changed cmake behaviour: executables are now always statically linked. When -DBUIL_SHARED_LIBS option is ON (the default), the shared versions of the libraries are also built (but executables remain linked against the static libraries).

This commit is contained in:
Antonin Descampe 2010-11-28 17:07:04 +00:00
parent fb6d84918d
commit e33c029fdb
2 changed files with 44 additions and 17 deletions

View File

@ -27,16 +27,14 @@ ENDIF(DONT_HAVE_GETOPT)
# Do the proper thing when building static...if only there was configured
# headers or def files instead
IF(NOT BUILD_SHARED_LIBS)
ADD_DEFINITIONS(-DOPJ_STATIC)
ENDIF(NOT BUILD_SHARED_LIBS)
#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} ${OPJ_PREFIX}openjp3dvm) # ${TIFF_LIBRARIES})
TARGET_LINK_LIBRARIES(${exe} ${OPENJPEG_LIBRARY_NAME}_JP3D.static) # ${TIFF_LIBRARIES})
# On unix you need to link to the math library:
IF(UNIX)
TARGET_LINK_LIBRARIES(${exe} m)

View File

@ -10,25 +10,54 @@ SET(JP3DVM_SRCS
bio.c cio.c dwt.c event.c jp3d.c jp3d_lib.c mct.c mqc.c openjpeg.c pi.c raw.c t1.c t1_3d.c t2.c tcd.c tgt.c volume.c
)
# Pass proper definition to preprocessor to generate shared lib
IF(WIN32)
IF(BUILD_SHARED_LIBS)
ADD_DEFINITIONS(-DOPJ_EXPORTS)
ELSE(BUILD_SHARED_LIBS)
ADD_DEFINITIONS(-DOPJ_STATIC)
ENDIF(BUILD_SHARED_LIBS)
ENDIF(WIN32)
IF(LCMS_INCLUDE_DIR)
INCLUDE_DIRECTORIES( ${LCMS_INCLUDE_DIR} )
ENDIF(LCMS_INCLUDE_DIR)
# Create the library
#ADD_LIBRARY(${OPENJPEG_LIBRARY_NAME} ${OPENJPEG_SRCS})
ADD_LIBRARY(${OPJ_PREFIX}openjp3dvm ${JP3DVM_SRCS})
SET_TARGET_PROPERTIES(${OPJ_PREFIX}openjp3dvm
# Build the static library
IF(WIN32)
ADD_DEFINITIONS(-DOPJ_STATIC)
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
PROPERTIES
VERSION 1.3.0
SOVERSION 1)
IF(LCMS_LIB)
TARGET_LINK_LIBRARIES(${OPENJPEG_LIBRARY_NAME}_JP3D.static ${LCMS_LIB})
ENDIF(LCMS_LIB)
# Install library
INSTALL_TARGETS(/lib/ ${OPJ_PREFIX}openjp3dvm)
INSTALL(TARGETS ${OPENJPEG_LIBRARY_NAME}_JP3D.static
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