Une MAJ de sécurité est nécessaire sur notre version actuelle. Elle sera effectuée lundi 02/08 entre 12h30 et 13h. L'interruption de service devrait durer quelques minutes (probablement moins de 5 minutes).

CMakeLists.txt 7.25 KB
Newer Older
1 2
## Version: $Id$
##
3
######################################################################
4 5 6 7 8
##
### Commentary:
##
######################################################################
##
9
### Change Log:
10
##
11
######################################################################
12 13
##
### Code:
14 15 16 17

project(dtkLog)

## #################################################################
Julien Wintz's avatar
Julien Wintz committed
18
## Sources
19 20 21
## #################################################################

set(${PROJECT_NAME}_HEADERS
NICLAUSSE Nicolas's avatar
NICLAUSSE Nicolas committed
22
  dtkLog
Julien Wintz's avatar
Julien Wintz committed
23 24 25 26
  dtkLog.h
  dtkLogger.h
  dtkLogger_p.h
  dtkLogEngine.h
27 28
  dtkLogDestination.h
  dtkLogModel.h)
29 30

set(${PROJECT_NAME}_SOURCES
Julien Wintz's avatar
Julien Wintz committed
31 32 33
  dtkLog.cpp
  dtkLogger.cpp
  dtkLogEngine.cpp
34 35
  dtkLogDestination.cpp
  dtkLogModel.cpp)
36

37 38 39 40 41 42 43 44 45 46
## #################################################################
## Wrapping
## #################################################################

set(${PROJECT_NAME}_SOURCES_WRAP)

if(DTK_BUILD_WRAPPERS AND SWIG_FOUND)

  configure_file(${CMAKE_CURRENT_SOURCE_DIR}/dtkLog.i ${CMAKE_BINARY_DIR}/dtkLog.i COPYONLY)

47
  set(${PROJECT_NAME}_WRAP_DEPENDS ${CMAKE_BINARY_DIR}/dtkLog.i ${${PROJECT_NAME}_HEADERS})
48 49 50

  if (DTK_WRAPPING_PYTHON)
    if (PYTHONLIBS_FOUND)
Julien Wintz's avatar
Julien Wintz committed
51
      dtk_wrap(${PROJECT_NAME} ${PROJECT_NAME}_SOURCES_WRAP dtklog python ${PROJECT_SOURCE_DIR}/dtkLog.i "${${PROJECT_NAME}_WRAP_DEPENDS}" "${CMAKE_SOURCE_DIR}/src;${CMAKE_CURRENT_SOURCE_DIR};${CMAKE_SOURCE_DIR}/wrp/dtkBase;${CMAKE_SOURCE_DIR}/wrp/QtCore")
52 53

      set_property(SOURCE dtkLog_wrap_python.cpp PROPERTY SKIP_AUTOMOC ON)
54 55 56 57 58
    endif()
  endif()

  if (DTK_WRAPPING_TCL)
    if (TCL_FOUND)
59
      dtk_wrap(${PROJECT_NAME} ${PROJECT_NAME}_SOURCES_WRAP dtklog tcl ${PROJECT_SOURCE_DIR}/dtkLog.i "${${PROJECT_NAME}_WRAP_DEPENDS}" ".")
60 61 62 63
    endif()
  endif()

  if (DTK_WRAPPING_CSHARP)
64
    dtk_wrap(${PROJECT_NAME} ${PROJECT_NAME}_SOURCES_WRAP dtklog csharp ${PROJECT_SOURCE_DIR}/dtkLog.i "${${PROJECT_NAME}_WRAP_DEPENDS}" ".")
65 66 67
  endif()
endif()

68 69 70 71
## #################################################################
## Build rules
## #################################################################

72
add_library(${PROJECT_NAME} SHARED
73
  ${${PROJECT_NAME}_SOURCES}
74
  ${${PROJECT_NAME}_SOURCES_WRAP}
75
  ${${PROJECT_NAME}_HEADERS})
Julien Wintz's avatar
Julien Wintz committed
76

77 78 79 80
## #################################################################
## Link rules
## #################################################################

81
target_link_libraries(${PROJECT_NAME} Qt5::Core)
Julien Wintz's avatar
Julien Wintz committed
82

83 84 85 86 87 88 89 90 91 92 93 94
if(DTK_BUILD_WRAPPERS AND SWIG_FOUND)

 if (DTK_WRAPPING_TCL AND TCL_FOUND)
   target_link_libraries(${PROJECT_NAME} ${TCL_LIBRARY})
 endif()

  if(DTK_WRAPPING_PYTHON AND PYTHONLIBS_FOUND)
      target_link_libraries(${PROJECT_NAME} ${PYTHON_LIBRARIES})
  endif()

endif(DTK_BUILD_WRAPPERS AND SWIG_FOUND)

Julien Wintz's avatar
Julien Wintz committed
95 96 97
## #################################################################
## Target properties
## #################################################################
98

99 100
set_target_properties(${PROJECT_NAME} PROPERTIES CXX_VISIBILITY_PRESET hidden)
set_target_properties(${PROJECT_NAME} PROPERTIES VISIBILITY_INLINES_HIDDEN 1)
101 102
set_target_properties(${PROJECT_NAME} PROPERTIES MACOSX_RPATH 0)
set_target_properties(${PROJECT_NAME} PROPERTIES INSTALL_NAME_DIR "${CMAKE_INSTALL_PREFIX}/${CMAKE_INSTALL_LIBDIR}")
Julien Wintz's avatar
Julien Wintz committed
103
set_target_properties(${PROJECT_NAME} PROPERTIES INSTALL_RPATH    "${CMAKE_INSTALL_PREFIX}/${CMAKE_INSTALL_LIBDIR}")
104 105
set_target_properties(${PROJECT_NAME} PROPERTIES VERSION   ${dtk_VERSION}
                                                 SOVERSION ${dtk_VERSION_MAJOR})
106

107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122
## #################################################################
## Export header file
## #################################################################

generate_export_header(${PROJECT_NAME}
  EXPORT_FILE_NAME "${PROJECT_NAME}Export.h")

add_custom_command(TARGET ${PROJECT_NAME} PRE_BUILD
  COMMAND ${CMAKE_COMMAND} ARGS -E copy_if_different "${${PROJECT_NAME}_BINARY_DIR}/${PROJECT_NAME}Export.h" "${CMAKE_BINARY_DIR}"
  COMMAND ${CMAKE_COMMAND} ARGS -E copy_if_different "${${PROJECT_NAME}_BINARY_DIR}/${PROJECT_NAME}Export.h" "${CMAKE_BINARY_DIR}/${PROJECT_NAME}Export")

set(${PROJECT_NAME}_HEADERS
  ${${PROJECT_NAME}_HEADERS}
 "${CMAKE_BINARY_DIR}/${PROJECT_NAME}Export"
 "${CMAKE_BINARY_DIR}/${PROJECT_NAME}Export.h")

123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 148 149 150 151 152 153 154 155 156 157 158 159 160 161 162 163 164 165 166 167 168 169 170 171 172 173 174
## #################################################################
## Handling of generated script modules
## #################################################################

set(${PROJECT_NAME}_MODULES)

if(DTK_BUILD_WRAPPERS AND SWIG_FOUND)

  if(DTK_WRAPPING_PYTHON AND PYTHONLIBS_FOUND )

    add_custom_command(TARGET ${PROJECT_NAME} POST_BUILD
      DEPENDS ${PROJECT_SOURCE_DIR}/dtkLog.i
      COMMAND ${CMAKE_COMMAND} ARGS -E make_directory ${CMAKE_BINARY_DIR}/modules
      COMMAND ${CMAKE_COMMAND} ARGS -E copy_if_different ${${PROJECT_NAME}_BINARY_DIR}/dtklog.py ${CMAKE_BINARY_DIR}/modules
      COMMENT "-- Moving python modules to ${CMAKE_BINARY_DIR}/modules")

    set(${PROJECT_NAME}_MODULES ${CMAKE_BINARY_DIR}/modules/dtklog.py)

    if(APPLE)
      add_custom_command(TARGET ${PROJECT_NAME} POST_BUILD
        DEPENDS ${PROJECT_SOURCE_DIR}/dtkLog.i
        COMMAND ln -sf ../lib/libdtkLog.dylib _dtklog.so
        WORKING_DIRECTORY ${CMAKE_BINARY_DIR}/modules)

      set(${PROJECT_NAME}_MODULES ${${PROJECT_NAME}_MODULES} ${CMAKE_BINARY_DIR}/modules/_dtklog.so)
    endif(APPLE)

    if(UNIX AND NOT APPLE)
      add_custom_command(TARGET ${PROJECT_NAME} POST_BUILD
        DEPENDS ${PROJECT_SOURCE_DIR}/dtkLog.i
        COMMAND ln -fs ../${CMAKE_INSTALL_LIBDIR}/libdtkLog.so _dtklog.so
        WORKING_DIRECTORY ${CMAKE_BINARY_DIR}/modules)

      set(${PROJECT_NAME}_MODULES ${${PROJECT_NAME}_MODULES} ${CMAKE_BINARY_DIR}/modules/_dtklog.so)
    endif(UNIX AND NOT APPLE)

  endif(DTK_WRAPPING_PYTHON AND PYTHONLIBS_FOUND )

  if (DTK_WRAPPING_CSHARP)

    file(GLOB DTK_CSHARP_SOURCES "${${PROJECT_NAME}_BINARY_DIR}/*.cs")

    foreach(DTK_CSHARP_SOURCE ${DTK_CSHARP_SOURCES})
      add_custom_command(TARGET ${PROJECT_NAME} POST_BUILD
        DEPENDS ${PROJECT_SOURCE_DIR}/dtkLog.i
        COMMAND ${CMAKE_COMMAND} ARGS -E copy_if_different ${DTK_CSHARP_SOURCE} ${CMAKE_BINARY_DIR}/modules
        COMMENT "-- Moving csharp ${DTK_CSHARP_SOURCE} source to ${CMAKE_BINARY_DIR}/modules")
    endforeach(DTK_CSHARP_SOURCE ${DTK_CSHARP_SOURCES})
  endif (DTK_WRAPPING_CSHARP)

endif(DTK_BUILD_WRAPPERS AND SWIG_FOUND)

175 176 177
## ###################################################################
## Install rules - files
## ###################################################################
178

179 180 181
install(FILES ${${PROJECT_NAME}_HEADERS}
  DESTINATION include/${PROJECT_NAME}
    COMPONENT log)
182

183 184 185
## ###################################################################
## Install rules - targets
## ###################################################################
186 187

install(TARGETS ${PROJECT_NAME}
NICLAUSSE Nicolas's avatar
NICLAUSSE Nicolas committed
188
    DESTINATION ${CMAKE_INSTALL_LIBDIR}
189 190
      COMPONENT log
         EXPORT dtkDepends)
191

192 193 194 195 196 197 198 199 200 201 202
## ###################################################################
## Install rules - modules
## ###################################################################

if(SWIG_FOUND)
  if (DTK_WRAPPING_PYTHON AND PYTHONLIBS_FOUND)
    install(FILES ${${PROJECT_NAME}_MODULES} DESTINATION modules)
    install(FILES ${CMAKE_BINARY_DIR}/dtkLog.i DESTINATION wrp/dtkLog)
  endif()
endif()

203 204
######################################################################
### CMakeLists.txt ends here