]> Creatis software - cpPlugins.git/commitdiff
...
authorLeonardo Flórez-Valencia <florez-l@javeriana.edu.co>
Thu, 28 Sep 2017 21:41:09 +0000 (16:41 -0500)
committerLeonardo Flórez-Valencia <florez-l@javeriana.edu.co>
Thu, 28 Sep 2017 21:41:09 +0000 (16:41 -0500)
CMakeLists.txt
cmake/Functions.cmake
lib/cpPlugins/CMakeLists.txt
lib/ivq/CMakeLists.txt

index 335f9e9e322ce136e8f8f306b83f8a6d6fa1cbe8..cc162d4300d31c5ebc074e9ebafc90bb417a7a22 100644 (file)
@@ -52,6 +52,6 @@ endif(VTK_FOUND)
 subdirs(lib)
 
 ## == Installation commands
-include(cmake/InstallCommands.cmake)
+## include(cmake/InstallCommands.cmake)
 
 ## eof - $RCSfile$
index 8ca0f15bb97ebb1a6972bca0895125f83fea1509..53046e686e1c6512001b2c143a18493e9bb48fd2 100644 (file)
@@ -3,18 +3,28 @@
 ## =========================================================================
 
 ## -------------------------------------------------------------------------
-function(BuildLibrary lib typ src maj min rel)
+function(BuildLibrary lib typ)
+set(options RECURRENT INSTALL_ALL INSTALL_BIN INSTALL_DEV)
+set(oneValueArgs)
+set(multiValueArgs SOURCE VERSION LINKS)
+cmake_parse_arguments(
+  BuildLibrary "${options}" "${oneValueArgs}" "${multiValueArgs}" ${ARGN}
+  )
 
 ## -- Get sources
 set(_files)
-foreach(_s ${src})
+foreach(_s ${BuildLibrary_SOURCE})
 
   ## -- Canonicalize path
   get_filename_component(_p "${_s}" ABSOLUTE)
 
   ## -- Check type of input
   if(IS_DIRECTORY ${_p})
-    file(GLOB _f "${_p}/*")
+    if(BuildLibrary_RECURRENT)
+      file(GLOB_RECURSE _f "${_p}/*")
+    else(BuildLibrary_RECURRENT)
+      file(GLOB _f "${_p}/*")
+    endif(BuildLibrary_RECURRENT)
     foreach(_x ${_f})
       if(NOT IS_DIRECTORY ${_x})
         list(APPEND _files ${_x})
@@ -76,39 +86,62 @@ if(${_qui_len} GREATER 0)
   qt5_wrap_ui(_qui_hpp ${_qui})
 endif(${_qui_len} GREATER 0)
 
-## -- Real build
-add_library(${lib} ${typ} ${_cpp} ${_hpp} ${_qui_hpp})
+if(_cpp)
 
-## -- Header creation
-generate_export_header(${lib})
-set_property(TARGET ${lib} PROPERTY VERSION "${maj}.${min}.${rel}")
-set_property(TARGET ${lib} PROPERTY SOVERSION ${maj})
-set_property(TARGET ${lib} PROPERTY INTERFACE_${lib}_MAJOR_VERSION ${maj})
-set_property(TARGET ${lib} APPEND PROPERTY COMPATIBLE_INTERFACE_STRING ${maj})
+  ## -- Real build
+  add_library(${lib} ${typ} ${_cpp} ${_hpp} ${_qui_hpp})
 
-## -- Link library
-target_link_libraries(${lib} PUBLIC ${ARGN})
+  ## -- Header creation
+  generate_export_header(${lib})
+
+  ## -- Put version strings
+  if(BuildLibrary_VERSION)
+    list(GET BuildLibrary_VERSION 0 _a)
+    list(GET BuildLibrary_VERSION 1 _b)
+    list(GET BuildLibrary_VERSION 2 _c)
+    set_property(TARGET ${lib} PROPERTY VERSION "${_a}.${_b}.${_c}")
+    set_property(TARGET ${lib} PROPERTY SOVERSION ${_a})
+    set_property(TARGET ${lib} PROPERTY INTERFACE_${lib}_MAJOR_VERSION ${_a})
+    set_property(
+      TARGET ${lib} APPEND PROPERTY COMPATIBLE_INTERFACE_STRING ${_a}
+      )
+  endif(BuildLibrary_VERSION)
+
+  ## -- Link library
+  if(BuildLibrary_LINKS)
+    target_link_libraries(${lib} PUBLIC ${BuildLibrary_LINKS})
+  endif(BuildLibrary_LINKS)
+
+endif(_cpp)
 
 ## -- Installation rules
-option(${lib}_INSTALL_DEVEL "Install development files for ${lib}" OFF)
-string(COMPARE EQUAL "${type}" "SHARED" _cmp)
-if(_cmp OR ${lib}_INSTALL_DEVEL)
-  install(
-    TARGETS ${lib}
-    EXPORT "${targets_export_name}"
-    LIBRARY DESTINATION "lib"
-    ARCHIVE DESTINATION "lib"
-    RUNTIME DESTINATION "bin"
-    INCLUDES DESTINATION "${include_install_dir}"
-    )
-endif(_cmp OR ${lib}_INSTALL_DEVEL)
-if(${lib}_INSTALL_DEVEL)
+if(BuildLibrary_INSTALL_ALL)
+  set(BuildLibrary_INSTALL_BIN ${BuildLibrary_INSTALL_ALL})
+  set(BuildLibrary_INSTALL_DEV ${BuildLibrary_INSTALL_ALL})
+endif(BuildLibrary_INSTALL_ALL)
+
+## -- Installation rules
+if(_cpp)
+  if(BuildLibrary_INSTALL_BIN)
+    install(
+      TARGETS ${lib}
+      EXPORT "${targets_export_name}"
+      LIBRARY DESTINATION "lib"
+      ARCHIVE DESTINATION "lib"
+      RUNTIME DESTINATION "bin"
+      INCLUDES DESTINATION "${include_install_dir}"
+      )
+  endif(BuildLibrary_INSTALL_BIN)
+endif(_cpp)
+if(BuildLibrary_INSTALL_DEV)
   string(TOLOWER ${lib} _lower_lib)
-  set(
-    _install_hdr
-    ${_hpp}
-    ${CMAKE_CURRENT_BINARY_DIR}/${_lower_lib}_export.h
-    )
+  set(_install_hdr ${_hpp})
+  if(_cpp)
+    list(
+      APPEND _install_hdr
+      ${CMAKE_CURRENT_BINARY_DIR}/${_lower_lib}_export.h
+      )
+  endif(_cpp)
   set(_install_dirs)
   foreach(_h ${_install_hdr})
     string(REPLACE ${CMAKE_CURRENT_SOURCE_DIR} "" _h_name ${_h})
@@ -123,19 +156,27 @@ if(${lib}_INSTALL_DEVEL)
       DESTINATION "${_h_dir}"
       )
   endforeach(_h)
-endif(${lib}_INSTALL_DEVEL)
+endif(BuildLibrary_INSTALL_DEV)
 
 endfunction()
 
-## -------------------------------------------------------------------------
-function(BuildLibraryRecursive lib typ dir maj min rel)
-
-## -- Globbing directory
-file(GLOB_RECURSE _files "${dir}/*")
-
-## -- Build library
-BuildLibrary(${lib} ${typ} "${_files}" ${maj} ${min} ${rel} ${ARGN})
-
-endfunction()
+### -------------------------------------------------------------------------
+#function(BuildApplication app)
+#option(BUILD_${app} "Build ${app}" OFF)
+#if(BUILD_${app})
+#  ## -- Use a static library
+#  BuildLibraryRecursive(
+#    _${app}_ STATIC ${CMAKE_CURRENT_SOURCE_DIR} 0 0 0 ${ARGN}
+#    )
+
+#  ## -- Create an empty application
+#  set(_m ${CMAKE_CURRENT_BINARY_DIR}/__main__${app}.cxx)
+#  file(WRITE ${_m} "// Automatically generated dummy file")
+#  add_executable(${app} ${EXECUTABLE_TYPE} ${_m})
+
+#  ## -- Link it against static library
+#  target_link_libraries(${app} PUBLIC _${app}_)
+#endif(BUILD_${app})
+#endfunction()
 
 ## eof - $RCSfile$
index b663bc136ff3a6692c6bb472b20bc5b4736115f0..5d8922f92429ed0299c5d812bb972b7ca3c50809 100644 (file)
@@ -2,10 +2,12 @@
 ## @author Leonardo Florez-Valencia (florez-l@javeriana.edu.co)
 ## =========================================================================
 
-BuildLibraryRecursive(
-  cpPlugins SHARED .
-  ${prj_MAJ} ${prj_MIN} ${prj_REL}
-  ${ITK_LIBRARIES} ${VTK_LIBRARIES} 
+BuildLibrary(
+  cpPlugins SHARED
+  RECURRENT INSTALL_ALL
+  SOURCE .
+  VERSION ${prj_MAJ} ${prj_MIN} ${prj_REL}
+  LINKS ${ITK_LIBRARIES} ${VTK_LIBRARIES}
   )
 
 ## eof - $RCSfile$
index 1a55abcc242bc6096bd6d904c26b4cbafd835bb6..8d4a985e90d04d97eae501755043d9f8ae238491 100644 (file)
@@ -16,10 +16,13 @@ if(BUILD_ivq)
 
   ## -- Build
   BuildLibrary(
-    ivq SHARED "${_dirs}"
-    ${prj_MAJ} ${prj_MIN} ${prj_REL}
-    ${ITK_LIBRARIES} ${VTK_LIBRARIES}
+    ivq SHARED
+    INSTALL_ALL
+    SOURCE ${_dirs}
+    VERSION ${prj_MAJ} ${prj_MIN} ${prj_REL}
+    LINKS ${ITK_LIBRARIES} ${VTK_LIBRARIES}
     )
+
 endif(BUILD_ivq)
 
 ## eof - $RCSfile$