Commit 87bc196e authored by saubatn's avatar saubatn
Browse files

FIXED bug 195.

           CamiTK macros (extensions libraries, applications) now consider EXTERNAL LIBRARIES for linking with -debug postfix (for MSVC), including static ones.

git-svn-id: svn+ssh://scm.forge.imag.fr/var/lib/gforge/chroot/scmrepos/svn/camitk/trunk/camitk@959 ec899d31-69d1-42ba-9299-647d76f65fb3
parent b384c989
......@@ -376,7 +376,7 @@ add_definitions(-D_CRT_SECURE_NO_WARNINGS)
# add lib as a camitk library
camitk_library(SHARED
SOURCES ${monitoring_SRCS}
TARGET_LINK_LIBRARIES ${monitoring_LIBRARIES}
LIBRARIES ${monitoring_LIBRARIES}
INCLUDE_DIRECTORIES ${monitoring_INCLUDE_DIR}
LINK_DIRECTORIES ${monitoring_link}
NEEDS_LIBXML2
......
......@@ -264,6 +264,21 @@ macro(camitk_application)
endif()
endif()
# consider additional external libraries (static or shared) for linking
set(EXTERNAL_LIBRARIES)
if(${APPLICATION_NAME_CMAKE}_LIBRARIES)
foreach(EXTERNAL_LIBRARY ${${APPLICATION_NAME_CMAKE}_LIBRARIES})
if (MSVC)
set(EXTERNAL_LIBRARIES ${EXTERNAL_LIBRARIES}
debug ${EXTERNAL_LIBRARY}${CAMITK_DEBUG_POSTFIX}
optimized ${EXTERNAL_LIBRARY}
)
else()
set(EXTERNAL_LIBRARIES ${EXTERNAL_LIBRARIES} ${EXTERNAL_LIBRARY})
endif()
endforeach()
endif()
# set the directories where to seek for static and dynamic libraries at linking time.
link_directories(${CAMITK_LINK_DIRECTORIES})
......@@ -348,7 +363,7 @@ macro(camitk_application)
endif()
# Set the libraries needed to build the application target
target_link_libraries(${APPLICATION_TARGET_NAME} ${COMPONENT_EXTENSION_LIBRARIES} ${ACTION_EXTENSION_LIBRARIES} ${CAMITK_LIBRARIES} ${QT_LIBRARIES_WITH_QTXML} ${CAMITK_CORE_LIBRARIES} ${CEP_LIBRARIES} ${XERCESC_LIBRARY} ${ITK_LIBRARIES} ${${APPLICATION_NAME_CMAKE}_LIBRARIES} ${PYTHON_LIBRARIES})
target_link_libraries(${APPLICATION_TARGET_NAME} ${COMPONENT_EXTENSION_LIBRARIES} ${ACTION_EXTENSION_LIBRARIES} ${CAMITK_LIBRARIES} ${QT_LIBRARIES_WITH_QTXML} ${CAMITK_CORE_LIBRARIES} ${CEP_LIBRARIES} ${XERCESC_LIBRARY} ${ITK_LIBRARIES} ${PYTHON_LIBRARIES} ${EXTERNAL_LIBRARIES})
# installation
install(TARGETS ${APPLICATION_TARGET_NAME}
......
......@@ -346,6 +346,21 @@ macro(camitk_extension)
endforeach()
endif()
# consider additional external libraries (static or shared) for linking
set(EXTERNAL_LIBRARIES)
if(${EXTENSION_NAME_CMAKE}_LIBRARIES)
foreach(EXTERNAL_LIBRARY ${${EXTENSION_NAME_CMAKE}_LIBRARIES})
if (MSVC)
set(EXTERNAL_LIBRARIES ${EXTERNAL_LIBRARIES}
debug ${EXTERNAL_LIBRARY}${CAMITK_DEBUG_POSTFIX}
optimized ${EXTERNAL_LIBRARY}
)
else()
set(EXTERNAL_LIBRARIES ${EXTERNAL_LIBRARIES} ${EXTERNAL_LIBRARY})
endif()
endforeach()
endif()
# check for libs in all known camitk dir + actions subdir (beware of the plateform bin or lib?)
link_directories(${CAMITK_LINK_DIRECTORIES})
......@@ -377,7 +392,7 @@ macro(camitk_extension)
# Set the libraries required to link the target
# Any component or action has to be linked with ${CAMITK_CORE_LIBRARIES} and with all its dependencies
target_link_libraries(${${TYPE_EXTENSION_CMAKE}_TARGET_NAME} ${CAMITK_LIBRARIES} ${QT_LIBRARIES_WITH_QTXML} ${CAMITK_CORE_LIBRARIES} ${COMPONENT_EXTENSION_LIBRARIES} ${ACTION_EXTENSION_LIBRARIES} ${ITK_LIBRARIES} ${LIBXML2_LIBRARIES} ${OpenCV_LIBRARIES} ${IGSTK_LIBRARIES} ${XERCESC_LIBRARY} ${GDCM_LIBRARIES} ${CEP_LIBRARIES} ${${EXTENSION_NAME_CMAKE}_LIBRARIES})
target_link_libraries(${${TYPE_EXTENSION_CMAKE}_TARGET_NAME} ${CAMITK_LIBRARIES} ${QT_LIBRARIES_WITH_QTXML} ${CAMITK_CORE_LIBRARIES} ${COMPONENT_EXTENSION_LIBRARIES} ${ACTION_EXTENSION_LIBRARIES} ${ITK_LIBRARIES} ${LIBXML2_LIBRARIES} ${OpenCV_LIBRARIES} ${IGSTK_LIBRARIES} ${XERCESC_LIBRARY} ${GDCM_LIBRARIES} ${CEP_LIBRARIES} ${EXTERNAL_LIBRARIES})
# dependencies to core (only set for internal build)
add_dependencies(${${TYPE_EXTENSION_CMAKE}_TARGET_NAME} ${CAMITK_CORE_TARGET_LIB_NAME})
......
......@@ -15,7 +15,7 @@
#! camitk_library(
#! SHARED|STATIC
#! SOURCES source1.cpp source1.h...
#! TARGET_LINK_LIBRARIES lib1 lib2...
#! LIBRARIES lib1 lib2...
#! [INCLUDE_DIRECTORIES dir1 dir2...]
#! [NEEDS_LIBXML2]
#! [NEEDS_XERCESC]
......@@ -33,7 +33,7 @@
#! \param SHARED optional, if the library should be compiled as shared
#! \param SOURCES all sources to be included in the library
#! \param INCLUDE_DIRECTORIES all needed include directories (${CMAKE_CURRENT_SOURCE_DIR} and ${CMAKE_CURRENT_BINARY_DIR} are automatically added)
#! \param TARGET_LINK_LIBRARIES all the libraries to be used during the link
#! \param LIBRARIES all the libraries to be used during the link (shared or static)
#! \param NEEDS_LIBXML2 add this if the CEP library needs libxml2
#! \param NEEDS_XERCESC add this if your action / component needs XercesC library
#! \param NEEDS_XSD add this if your action needs Codesynthesis xsd cxx (xml schema compiler)
......@@ -55,7 +55,7 @@ macro(camitk_library)
get_directory_name(${CMAKE_CURRENT_SOURCE_DIR} DEFAULT_LIBRARY_NAME)
parse_arguments(${DEFAULT_LIBRARY_NAME_CMAKE}
"SOURCES;TARGET_LINK_LIBRARIES;INCLUDE_DIRECTORIES;LIBNAME;LINK_DIRECTORIES;HEADERS_TO_INSTALL;CEP_NAME;DESCRIPTION" # possible lists
"SOURCES;LIBRARIES;INCLUDE_DIRECTORIES;LIBNAME;LINK_DIRECTORIES;HEADERS_TO_INSTALL;CEP_NAME;DESCRIPTION" # possible lists
"SHARED;STATIC;NEEDS_LIBXML2;NEEDS_XERCESC;NEEDS_XSD;PUBLIC" # possible options
${ARGN}
)
......@@ -126,6 +126,21 @@ macro(camitk_library)
message(ERROR "${LIBRARY_TARGET_NAME}: xerces-c required because of XSD cxx, please set XERCESC_INCLUDE_DIR")
endif()
endif()
# consider additional external libraries (static or shared) for linking
set(EXTERNAL_LIBRARIES)
if(${DEFAULT_LIBRARY_NAME_CMAKE}_LIBRARIES)
foreach(EXTERNAL_LIBRARY ${${DEFAULT_LIBRARY_NAME_CMAKE}_LIBRARIES})
if (MSVC)
set(EXTERNAL_LIBRARIES ${EXTERNAL_LIBRARIES}
debug ${EXTERNAL_LIBRARY}${CAMITK_DEBUG_POSTFIX}
optimized ${EXTERNAL_LIBRARY}
)
else()
set(EXTERNAL_LIBRARIES ${EXTERNAL_LIBRARIES} ${EXTERNAL_LIBRARY})
endif()
endforeach()
endif()
# some additional link directories are needed
if (NOT "${${DEFAULT_LIBRARY_NAME_CMAKE}_LINK_DIRECTORIES}" STREQUAL "")
......@@ -214,7 +229,7 @@ macro(camitk_library)
endif()
#add libraries needed during the link
target_link_libraries(${LIBRARY_TARGET_NAME} ${${DEFAULT_LIBRARY_NAME_CMAKE}_TARGET_LINK_LIBRARIES} ${LIBXML2_LIBRARIES} ${XERCESC_LIBRARY})
target_link_libraries(${LIBRARY_TARGET_NAME} ${LIBXML2_LIBRARIES} ${XERCESC_LIBRARY} ${EXTERNAL_LIBRARIES})
# generate an install target for headers in include/{camitk-version}/libraries
if(${DEFAULT_LIBRARY_NAME_CMAKE}_HEADERS_TO_INSTALL)
......
......@@ -141,7 +141,7 @@ file(GLOB HEADERS_UPPERCASE "src/Qt*")
camitk_library(SHARED
SOURCES ${SRCS}
TARGET_LINK_LIBRARIES ${QT_LIBRARIES}
LIBRARIES ${QT_LIBRARIES}
PUBLIC #install directly in lib (or bin for Windows).
HEADERS_TO_INSTALL ${HEADERS_H} ${HEADERS_UPPERCASE}
CEP_NAME SDK
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment