#-----------------------------------------------------------------------------
# Code installing the files needed to find the library
# with the cmake command FIND_PACKAGE
-# Uses CREA_ADVANCED_INSTALL_LIBRARY macro
+# Uses CREA_ADVANCED_INSTALL_LIBRARY_FOR_CMAKE macro
#-----------------------------------------------------------------------------
#-----------------------------------------------------------------------------
${PROJECT_SOURCE_DIR}/AdditionalUsecrea.cmake.in)
# Invoke the macro
-CREA_ADVANCED_INSTALL_LIBRARY(${LIBRARY_NAME})
+CREA_ADVANCED_INSTALL_LIBRARY_FOR_CMAKE(${LIBRARY_NAME})
#-----------------------------------------------------------------------------
PROJECT(PROJECT_NAME)
+
+SET(PROJECT_MAJOR_VERSION 1)
+SET(PROJECT_MINOR_VERSION 0)
+SET(PROJECT_BUILD_VERSION 0)
+
+SET(CREA_VERBOSE_CMAKE TRUE)
+
+FIND_PACKAGE(crea REQUIRED)
+IF (crea_FOUND)
+ INCLUDE(${crea_USE_FILE})
+ENDIF(crea_FOUND)
+
+CREA_PREVENT_IN_SOURCE_BUILD()
+
+SET(USE_GDCM OFF)
+SET(USE_GDCM_VTK OFF)
+SET(USE_WXWIDGETS OFF)
+SET(USE_VTK OFF)
+SET(USE_ITK OFF)
+SET(USE_BOOST OFF)
+
+CREA_FIND_AND_USE_LIBRARIES()
+
+SET(EXECUTABLE_OUTPUT_PATH ${PROJECT_BINARY_DIR})
+SET(LIBRARY_OUTPUT_PATH ${PROJECT_BINARY_DIR})
+MARK_AS_ADVANCED(
+ CMAKE_BACKWARDS_COMPATIBILITY
+ EXECUTABLE_OUTPUT_PATH
+ LIBRARY_OUTPUT_PATH
+ )
+
+SUBDIRS(appli)
+SUBDIRS(lib)
--- /dev/null
+# Add a SUBDIRS command for each of your libraries
+# SUBDIRS(template_lib)
--- /dev/null
+#----------------------------------------------------------------------------
+# SET THE NAME OF YOUR LIBRARY
+SET ( LIBRARY_NAME MyLib )
+#----------------------------------------------------------------------------
+
+#----------------------------------------------------------------------------
+# CREATES A USER OPTION IN CMAKE
+OPTION ( BUILD_${LIBRARY_NAME} "Build ${LIBRARY_NAME} library ?" ON))
+#----------------------------------------------------------------------------
+
+#----------------------------------------------------------------------------
+IF ( BUILD_${LIBRARY_NAME} )
+#----------------------------------------------------------------------------
+
+ #----------------------------------------------------------------------------
+ # BUILD LIBRARY
+ #----------------------------------------------------------------------------
+
+ #----------------------------------------------------------------------------
+ # LIBRARY HEADERS (TO BE INSTALLED)
+ # EITHER LIST ALL .h IN CURRENT DIR USING NEXT LINE:
+ FILE(GLOB ${LIBRARY_NAME}_HEADERS "*.h")
+ # OR MANUALLY LIST YOUR HEADERS WITH NEXT COMMAND
+ # SET ( ${LIBRARY_NAME}_HEADERS
+ #
+ # )
+ #----------------------------------------------------------------------------
+
+ #----------------------------------------------------------------------------
+ # LIBRARY SOURCES (TO BE COMPILED)
+ # EITHER LIST ALL .cxx, *.cpp, *.cc IN CURRENT DIR USING NEXT LINE:
+ FILE(GLOB ${LIBRARY_NAME}_SOURCES *.cxx *.cpp *.cc)
+ # OR MANUALLY LIST YOUR FILES WITH NEXT COMMAND (WITHOUT EXTENSION)
+ # SET ( ${LIBRARY_NAME}_SOURCES
+ #
+ # )
+ #----------------------------------------------------------------------------
+
+ #----------------------------------------------------------------------------
+ # LIBRARY DEPENDENCIES (LIBRARIES TO LINK WITH)
+ SET ( ${LIBRARY_NAME}_LINK_LIBRARIES
+ ${crea_LIBRARIES}
+ # ${WXWIDGETS_LIBRARIES}
+ # ${VTK_LIBRARIES}
+ # ${ITK_LIBRARIES}
+ # ${GDCM_LIBRARIES}
+ # ${BOOST_LIBRARIES}
+ )
+ #----------------------------------------------------------------------------
+
+
+ #----------------------------------------------------------------------------
+ # MACRO WHICH DOES ALL THE JOB : BUILD AND INSTALL
+ CREA_ADD_LIBRARY( ${LIBRARY_NAME} )
+ #----------------------------------------------------------------------------
+
+
+ #---------------------------------------------------------------------------
+ENDIF ( BUILD_${LIBRARY_NAME} )
--- /dev/null
+# Creates and installs a library
+# Uses CREA_MANAGE_SHARED_LIBRARY and CREA_INSTALL_LIBRARY
+# hence the variables to be set for these are needed
+# Additionnaly one needs to set :
+# ${LIBRARY_NAME}_HEADERS : the list of headers to install
+# ${LIBRARY_NAME}_SOURCES : the list of files to compile to build the lib
+# ${LIBRARY_NAME}_LINK_LIBRARIES : the list of libs to link with
+MACRO(CREA_ADD_LIBRARY LIBRARY_NAME)
+
+ IF(CREA_VERBOSE_CMAKE)
+ MESSAGE(STATUS "** Creating library ${LIBRARY_NAME}")
+ MESSAGE(STATUS " Headers : ${${LIBRARY_NAME}_HEADERS}")
+ MESSAGE(STATUS " Sources : ${${LIBRARY_NAME}_SOURCES}")
+ MESSAGE(STATUS " Link libs: ${${LIBRARY_NAME}_LINK_LIBRARIES}")
+ ENDIF(CREA_VERBOSE_CMAKE)
+
+
+ # MANAGE SHARED LIB
+ CREA_MANAGE_SHARED_LIBRARY(${LIBRARY_NAME})
+
+ # CREATE THE TARGET
+ ADD_LIBRARY(${LIBRARY_NAME} ${${LIBRARY_NAME}_SHARED} ${${LIBRARY_NAME}_SOURCES})
+
+ # LINK
+ TARGET_LINK_LIBRARIES(${LIBRARY_NAME} ${${LIBRARY_NAME}_LINK_LIBRARIES})
+
+ # INSTALLS LIBRARY FOR CMAKE
+ CREA_INSTALL_LIBRARY_FOR_CMAKE(${LIBRARY_NAME})
+
+ # INSTALLS LIBRARY
+ INSTALL(
+ FILES ${${LIBRARY_NAME}_HEADERS}
+ DESTINATION ${${LIBRARY_NAME}_INSTALL_TREE_RELATIVE_INCLUDE_PATHS}
+ )
+ INSTALL(
+ TARGETS ${LIBRARY_NAME}
+ DESTINATION lib)
+
+
+ENDMACRO(CREA_ADD_LIBRARY)
+
#-----------------------------------------------------------------------------
-# Macro CREA_ADVANCED_INSTALL_LIBRARY
+# Macro CREA_ADVANCED_INSTALL_LIBRARY_FOR_CMAKE
# Creates and install the cmake files which allow
-# to find a library by the cmake command FIND_PACKAGE.
+# to find the library by the cmake command FIND_PACKAGE.
#
# Inputs :
# --------
#
#-----------------------------------------------------------------------------
-MACRO(CREA_ADVANCED_INSTALL_LIBRARY LIBRARY_NAME)
+MACRO(CREA_ADVANCED_INSTALL_LIBRARY_FOR_CMAKE LIBRARY_NAME)
#---------------------------------------------------------------------------
# Sets the common values to build tree and install tree configs
#---------------------------------------------------------------------------
#-- INSTALL TREE configuration
+
+
SET(CILC_BUILD_TREE_CONFIGURATION FALSE)
- # CREAte work directory to put the configured files because
+ # Create work directory to put the configured files because
# if the user invoked the macro at the root of the build tree the files
# would overwrite those configured for the build tree
SET(CILC_WORK_DIR ${CMAKE_CURRENT_BINARY_DIR}/InstallLibraryForCMake_tmp)
ENDIF(WIN32)
+
# UseLIBRARY_NAME.cmake
CONFIGURE_FILE(
${CREA_CMAKE_DIR}/InstallLibraryForCMake_UseLibrary.cmake.in
-ENDMACRO(CREA_ADVANCED_INSTALL_LIBRARY)
+ENDMACRO(CREA_ADVANCED_INSTALL_LIBRARY_FOR_CMAKE)
#-----------------------------------------------------------------------------
#-----------------------------------------------------------------------------
-MACRO(CREA_INSTALL_LIBRARY LIBRARY_NAME)
+MACRO(CREA_INSTALL_LIBRARY_FOR_CMAKE LIBRARY_NAME)
# Sets the settings to default values
SET(${LIBRARY_NAME}_INSTALL_FOLDER ${LIBRARY_NAME})
SET(${LIBRARY_NAME}_INSTALL_TREE_RELATIVE_LIBRARY_PATHS lib)
# Invoke the advanced macro
- CREA_ADVANCED_INSTALL_LIBRARY(${LIBRARY_NAME})
+ CREA_ADVANCED_INSTALL_LIBRARY_FOR_CMAKE(${LIBRARY_NAME})
-ENDMACRO(CREA_INSTALL_LIBRARY)
+ENDMACRO(CREA_INSTALL_LIBRARY_FOR_CMAKE)
#-----------------------------------------------------------------------------
--- /dev/null
+# Manages the shared library creation/use
+# * Creates an option ${LIBRARY_NAME}_BUILD_SHARED
+# * Generates the file ${LIBRARY_NAME}DLLImportExport.h which
+# defines the symbols ${LIBRARY_NAME}_EXPORT and ${LIBRARY_NAME}_CDECL
+# to be used in exported classes/functions declarations
+MACRO(CREA_MANAGE_SHARED_LIBRARY LIBRARY_NAME)
+
+ # STATIC OR DYNAMIC (SHARED) ?
+ OPTION( ${LIBRARY_NAME}_BUILD_SHARED
+ "Build ${LIBRARY_NAME} as a shared library (dynamic) ?" ON)
+ IF (${LIBRARY_NAME}_BUILD_SHARED)
+ SET(${LIBRARY_NAME}_SHARED SHARED)
+ CREA_DEFINE(${LIBRARY_NAME}_BUILD_SHARED)
+ ENDIF(${LIBRARY_NAME}_BUILD_SHARED)
+
+ CREA_DEFINE(${LIBRARY_NAME}_EXPORT_SYMBOLS)
+
+ # ADDS CURRENT BINARY DIR TO INCLUDE DIRS
+ INCLUDE_DIRECTORIES(${CMAKE_CURRENT_BINARY_DIR})
+
+ # CONFIGURES ${LIBRARY_NAME}DLLImportExport.h
+ CONFIGURE_FILE(
+ ${CREA_CMAKE_DIR}/LIBRARY_NAMEDLLImportExport.h.in
+ ${CMAKE_CURRENT_BINARY_DIR}/${LIBRARY_NAME}DLLImportExport.h
+ @ONLY IMMEDIATE
+ )
+ # ADDS IT TO THE LIST OF HEADERS
+ SET(${LIBRARY_NAME}_HEADERS
+ ${${LIBRARY_NAME}_HEADERS}
+ ${CMAKE_CURRENT_BINARY_DIR}/${LIBRARY_NAME}DLLImportExport.h
+ )
+
+
+ENDMACRO(CREA_MANAGE_SHARED_LIBRARY LIBRARY_NAME)
+
#========================================================================
#========================================================================
-INCLUDE( ${CREA_CMAKE_DIR}/CREAMacro_InstallLibrary.cmake )
+INCLUDE( ${CREA_CMAKE_DIR}/CREAMacro_InstallLibraryForCMake.cmake )
+#========================================================================
+
+#========================================================================
+INCLUDE( ${CREA_CMAKE_DIR}/CREAMacro_ManageSharedLibrary.cmake )
+#========================================================================
+
+#========================================================================
+INCLUDE( ${CREA_CMAKE_DIR}/CREAMacro_AddLibrary.cmake )
#========================================================================
#========================================================================
--- /dev/null
+#ifndef __@LIBRARY_NAME@DLLImportExport_h_INCLUDED__
+#define __@LIBRARY_NAME@DLLImportExport_h_INCLUDED__
+
+// Automatically generated file which defines
+// the symbols @LIBRARY_NAME@_EXPORT and @LIBRARY_NAME@_CDECL
+// to be used for the definition of classes or functions
+// which must be exported when the lib is built as a shared lib on Windows
+// and imported when the shared lib is used by another program
+
+#if defined(_WIN32) && defined (@LIBRARY_NAME@_BUILD_SHARED)
+ #ifdef @LIBRARY_NAME@_EXPORT_SYMBOLS
+ #define @LIBRARY_NAME@_EXPORT __declspec( dllexport )
+#else
+ #define @LIBRARY_NAME@_EXPORT __declspec( dllimport )
+ #endif
+ #define @LIBRARY_NAME@_CDECL __cdecl
+#else
+ #define @LIBRARY_NAME@_EXPORT
+ #define @LIBRARY_NAME@_CDECL
+#endif // defined(_WIN32)
+
+#endif
+
+#-----------------------------------------------------------------------------
INCLUDE_DIRECTORIES(${CMAKE_CURRENT_BINARY_DIR})
+#-----------------------------------------------------------------------------
#-----------------------------------------------------------------------------
INCLUDE (${CMAKE_ROOT}/Modules/CheckIncludeFile.cmake)
#----------------------------------------------------------------------------
# INSTALLS LIBRARY
-FILE(GLOB HEADERS "*.h")
+FILE(GLOB crea_HEADERS "*.h")
INSTALL(
FILES ${HEADERS} ${CMAKE_CURRENT_BINARY_DIR}/creaConfigure.h
DESTINATION include/crea