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 e33c029fdb
commit c906c230fb
2 changed files with 11 additions and 41 deletions

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,50 +14,27 @@ 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)
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 ${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)
ELSE(BUILD_SHARED_LIBS)
ADD_DEFINITIONS(-DOPJ_STATIC)
ENDIF(BUILD_SHARED_LIBS)
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
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.shared ${LCMS_LIB})
TARGET_LINK_LIBRARIES(${OPENJPEG_LIBRARY_NAME}_JP3D ${LCMS_LIB})
ENDIF(LCMS_LIB)
# Install library
INSTALL(TARGETS ${OPENJPEG_LIBRARY_NAME}_JP3D.shared
INSTALL(TARGETS ${OPENJPEG_LIBRARY_NAME}_JP3D
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