From: Leonardo Florez-Valencia Date: Wed, 2 Nov 2016 04:14:10 +0000 (-0500) Subject: ... X-Git-Url: https://git.creatis.insa-lyon.fr/pubgit/?a=commitdiff_plain;h=a993dd7dc7f3154d00eed3d3a4796fb9e3ff582d;p=FrontAlgorithms.git ... --- diff --git a/CMakeLists.txt b/CMakeLists.txt index 3558050..fec6ee2 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -36,33 +36,26 @@ SET(prj_SHORT_VERSION "${prj_MAJOR_VERSION}") ## ===================================== INCLUDE(cmake/Restrictions.cmake) -INCLUDE(cmake/Functions.cmake) INCLUDE(cmake/KitwareTools.cmake) -INCLUDE(cmake/Options.cmake) - -## =========================== -## == Use all valid subdirs == -## =========================== - -SET( - _include_dirs - . - lib - ) +OPTION(USE_cpPlugins "Build cpPlugins-based code" OFF) IF(USE_cpPlugins) - LIST(APPEND _include_dirs lib/Instances) + FIND_PACKAGE(cpPlugins REQUIRED) + IF(USE_QT4) + INCLUDE(cmake/QtTools.cmake) + SET( + cpPlugins_Qt4_VTKWidget QVTKWidget + CACHE STRING "Base Qt4-based vtkRenderWindow" + ) + MARK_AS_ADVANCED(FORCE cpPlugins_Qt4_VTKWidget) + ENDIF(USE_QT4) ENDIF(USE_cpPlugins) -FOREACH(_dir ${_include_dirs}) - INCLUDE_DIRECTORIES( - ${PROJECT_SOURCE_DIR}/${_dir} - ${PROJECT_BINARY_DIR}/${_dir} - ) -ENDFOREACH(_dir) +INCLUDE(cmake/Functions.cmake) -## ======================== -## == Manage source code == -## ======================== +## =========================== +## == Build different parts == +## =========================== -SUBDIRS(cmake lib plugins appli) +## SUBDIRS(appli cmake lib plugins) +SUBDIRS(lib) ## eof - $RCSfile$ diff --git a/cmake/Functions.cmake b/cmake/Functions.cmake index 287e693..02ec213 100644 --- a/cmake/Functions.cmake +++ b/cmake/Functions.cmake @@ -59,49 +59,133 @@ ENDFUNCTION() ## ------------------------------------------------------------------------- FUNCTION( - CreateLib - lib_name - lib_dir - lib_type - lib_source_files - lib_header_files - lib_qt_ui_files - lib_version - lib_short_version + PrepareSourceFiles + out_sources_list + out_headers_list + out_headers_paths ) -## -- Configure inputs to be cmake-path compatible -NormPaths(_sources ${lib_source_files}) -NormPaths(_headers ${lib_header_files}) -NormPaths(_qt_uis ${lib_qt_ui_files}) +SET(_config_extensions .c.in .cpp.in .cxx.in .h.in .hpp.in .hxx.in .ui.in) +SET(_sources_extensions .c .cpp .cxx) +SET(_headers_extensions .h .hpp .hxx) +SET(_qt_ui_extensions .ui) +SET(_demangler_extensions .d) + +## -- Configure inputs +SET(_all_files) +FOREACH(_file ${ARGN}) + GET_FILENAME_COMPONENT(_ext ${_file} EXT) + LIST(FIND _config_extensions ${_ext} _cfg) + IF(NOT ${_cfg} EQUAL -1) + STRING( + REPLACE + ${PROJECT_SOURCE_DIR} + ${PROJECT_BINARY_DIR} + _file_bin + ${_file} + ) + STRING(LENGTH ${_file_bin} _file_bin_len) + MATH(EXPR _file_bin_len "${_file_bin_len}-3") + STRING(SUBSTRING ${_file_bin} 0 ${_file_bin_len} _file_bin) + CONFIGURE_FILE(${_file} ${_file_bin} @ONLY) + LIST(APPEND _all_files ${_file_bin}) + ELSE(NOT ${_cfg} EQUAL -1) + LIST(APPEND _all_files ${_file}) + ENDIF(NOT ${_cfg} EQUAL -1) +ENDFOREACH(_file) + +## -- Separate files +SET(_srcs) +SET(_hdrs) +SET(_qts) +SET(_demanglers) +FOREACH(_file ${_all_files}) + GET_FILENAME_COMPONENT(_ext ${_file} EXT) + LIST(FIND _sources_extensions ${_ext} _src) + LIST(FIND _headers_extensions ${_ext} _hdr) + LIST(FIND _qt_ui_extensions ${_ext} _ui) + LIST(FIND _demangler_extensions ${_ext} _dem) + IF(NOT ${_src} EQUAL -1) + LIST(APPEND _srcs ${_file}) + ENDIF(NOT ${_src} EQUAL -1) + IF(NOT ${_hdr} EQUAL -1) + LIST(APPEND _hdrs ${_file}) + ENDIF(NOT ${_hdr} EQUAL -1) + IF(NOT ${_ui} EQUAL -1) + LIST(APPEND _qts ${_file}) + ENDIF(NOT ${_ui} EQUAL -1) + IF(NOT ${_dem} EQUAL -1) + LIST(APPEND _demanglers ${_file}) + ENDIF(NOT ${_dem} EQUAL -1) +ENDFOREACH(_file) # -- Prepare Qt4-based code IF(Qt4_FOUND) ## -- Guess what headers sould be qt-moc'ed - Wrap_Qt_CPP(_qt_moc_sources ${_headers}) - IF(_qt_moc_sources) - SET(_sources ${_sources} ${_qt_moc_sources}) - ENDIF(_qt_moc_sources) + Wrap_Qt_CPP(_moc ${_hdrs}) + IF(_moc) + LIST(APPEND _srcs ${_moc}) + ENDIF(_moc) ## -- Guess what qt-ui's sould be qt-uic'ed ## -- Wrap qt-ui headers: this is equivalent to QT4_WRAP_UI except to change ## -- the output file - Wrap_Qt_UI(_qt_ui_headers ${_qt_uis}) - IF(_qt_ui_headers) - SET(_headers ${_headers} ${_qt_ui_headers}) - SET(_sources ${_sources} ${_qt_ui_headers}) - ENDIF(_qt_ui_headers) + Wrap_Qt_UI(_qt_hdrs ${_qts}) + IF(_qt_hdrs) + LIST(APPEND _hdrs ${_qt_hdrs}) + ENDIF(_qt_hdrs) ENDIF(Qt4_FOUND) -## -- Ok, compile library -IF(_sources) - NormPaths(_cur_binary_dir ${CMAKE_CURRENT_BINARY_DIR}) - ADD_LIBRARY(${lib_name} ${lib_type} ${_sources} ${_headers}) - #SET_TARGET_PROPERTIES( - # ${lib_name} - # PROPERTIES - # VERSION "${lib_version}" - # SOVERSION "${lib_short_version}" - # ) +## -- Create demanglers +FOREACH(_d ${_demanglers}) + STRING( + REPLACE + ${PROJECT_SOURCE_DIR} + ${PROJECT_BINARY_DIR} + _d_bin + ${_d} + ) + GET_FILENAME_COMPONENT(_d_path ${_d_bin} DIRECTORY) + GET_FILENAME_COMPONENT(_out_name ${_d_bin} NAME_WE) + SET(_d_out ${_d_path}/${_out_name}_Demanglers.h) + ADD_CUSTOM_COMMAND( + OUTPUT ${_d_out} + COMMAND ${CMAKE_COMMAND} -E make_directory ${_d_path} + COMMAND ${cpPlugins_bash_CreateDemanglers_APP} ${_d} ${_out_name} ${_d_out} + DEPENDS ${cpPlugins_bash_CreateDemanglers_APP} ${_d} + ) + LIST(APPEND _hdrs ${_d_out}) +ENDFOREACH(_d) + +## -- Real compilation +SET(_hdrs_paths) +FOREACH(_hdr ${_hdrs}) + GET_FILENAME_COMPONENT(_path ${_hdr} DIRECTORY) + LIST(FIND _hdrs_paths ${_path} _path_idx) + IF(${_path_idx} EQUAL -1) + LIST(APPEND _hdrs_paths ${_path}) + ENDIF(${_path_idx} EQUAL -1) +ENDFOREACH(_hdr) + +SET(${out_sources_list} ${_srcs} PARENT_SCOPE) +SET(${out_headers_list} ${_hdrs} PARENT_SCOPE) +SET(${out_headers_paths} ${_hdrs_paths} PARENT_SCOPE) + +ENDFUNCTION() + +## ------------------------------------------------------------------------- +FUNCTION( + CreateLib + lib_name + lib_type + ) +PrepareSourceFiles(_srcs _hdrs _paths ${ARGN}) +INCLUDE_DIRECTORIES( + ${_paths} + ${CMAKE_CURRENT_SOURCE_DIR} + ${CMAKE_CURRENT_BINARY_DIR} + ) +IF(_srcs) + ADD_LIBRARY(${lib_name} ${lib_type} ${_srcs} ${_hdrs}) GENERATE_EXPORT_HEADER( ${lib_name} BASE_NAME ${lib_name} @@ -109,348 +193,152 @@ IF(_sources) EXPORT_FILE_NAME ${lib_name}_Export.h STATIC_DEFINE ${lib_name}_BUILT_AS_STATIC ) - SET(${lib_name}_LIB ${lib_name} CACHE INTERNAL "Library ${lib_name}") -ENDIF(_sources) - + IF(${prj_NAME}_All_Headers) + SET(_hdr_tmp "${${prj_NAME}_All_Headers};${_hdrs}") + ELSE(${prj_NAME}_All_Headers) + SET(_hdr_tmp "${_hdrs}") + ENDIF(${prj_NAME}_All_Headers) + LIST(REMOVE_DUPLICATES _hdr_tmp) + SET(${prj_NAME}_All_Headers ${_hdr_tmp} CACHE INTERNAL "All headers." FORCE) +ENDIF(_srcs) ENDFUNCTION() ## ------------------------------------------------------------------------- FUNCTION( - LibFromDir + CompileLibFromDir lib_name - lib_dir lib_type - lib_source_dir - lib_version - lib_short_version - ) - -## -- Configure inputs to be cmake-path compatible -NormPaths(_global_source_dir ${PROJECT_SOURCE_DIR}) -NormPaths(_global_binary_dir ${PROJECT_BINARY_DIR}) -NormPaths(_source_dir ${lib_source_dir}) -STRING(REPLACE "${_global_source_dir}" "" _local_source_dir ${_source_dir}) -SET(_binary_dir ${_global_binary_dir}${_local_source_dir}) - -## -- Some useful variables -SET(_sources_extensions .c .cpp .cxx) -SET(_headers_extensions .h .hpp .hxx) -SET(_qt_ui_extensions .ui) -SET(_dirs ${_source_dir} ${_binary_dir}) -SET(_sources) -SET(_headers) -SET(_qt_uis) - -## -- Glob source code -FOREACH(_d ${_dirs}) - FOREACH(_e ${_sources_extensions}) - FILE(GLOB_RECURSE _f "${_d}/*${_e}") - SET(_sources ${_sources} ${_f}) - ENDFOREACH(_e) - FOREACH(_e ${_headers_extensions}) - FILE(GLOB_RECURSE _f "${_d}/*${_e}") - SET(_headers ${_headers} ${_f}) - ENDFOREACH(_e) - FOREACH(_e ${_qt_ui_extensions}) - FILE(GLOB_RECURSE _f "${_d}/*${_e}") - SET(_qt_uis ${_qt_uis} ${_f}) - ENDFOREACH(_e) -ENDFOREACH(_d) - -## -- Configure some files -FILE(GLOB_RECURSE _configs "${_source_dir}/*.in") -FOREACH(_c ${_configs}) - - ## -- Build input and output names - NormPaths(_input_file ${_c}) - GET_FILENAME_COMPONENT(_input_name ${_input_file} NAME) - GET_FILENAME_COMPONENT(_input_dir ${_input_file} DIRECTORY) - STRING(REPLACE ".in" "" _output_name ${_input_name}) - STRING(REPLACE "${_global_source_dir}" "" _output_dir ${_input_dir}) - SET(_output_file "${_global_binary_dir}${_output_dir}/${_output_name}") - - ## -- Configure file - CONFIGURE_FILE(${_input_file} ${_output_file} @ONLY) - - ## -- Add it to the correct list - GET_FILENAME_COMPONENT(_output_ext ${_output_name} EXT) - IF( - "${_output_ext}" STREQUAL ".h" - OR - "${_output_ext}" STREQUAL ".hpp" - OR - "${_output_ext}" STREQUAL ".hxx" - ) - SET(_headers ${_headers}) - ENDIF() - IF( - "${_output_ext}" STREQUAL ".c" - OR - "${_output_ext}" STREQUAL ".cpp" - OR - "${_output_ext}" STREQUAL ".cxx" - ) - SET(_sources ${_sources}) - ENDIF() - IF("${_output_ext}" STREQUAL ".ui") - SET(_qt_uis ${_qt_uis}) - ENDIF() -ENDFOREACH(_c) -IF(ARGN) - LIST(APPEND _sources ${ARGN}) -ENDIF(ARGN) - -## -- Create library -CreateLib( - ${lib_name} ${lib_dir} ${lib_type} - "${_sources}" "${_headers}" "${_qt_uis}" - "${lib_version}" "${lib_short_version}" + lib_dir ) - +FILE(GLOB_RECURSE _files "${lib_dir}/*") +CreateLib(${lib_name} ${lib_type} ${_files} ${ARGN}) ENDFUNCTION() ## ------------------------------------------------------------------------- FUNCTION( CompileInstances out_lib_name - lib_dir def_file number_of_files - prefix - version - short_version ) -## -- Configure inputs to be cmake-path compatible -NormPaths(_def_file ${def_file}) -GET_FILENAME_COMPONENT(_def_name ${_def_file} NAME_WE) -GET_FILENAME_COMPONENT(_def_dir ${_def_file} DIRECTORY) -NormPaths(_global_source_dir ${PROJECT_SOURCE_DIR}) -NormPaths(_global_binary_dir ${PROJECT_BINARY_DIR}) -STRING(REPLACE "${_global_source_dir}" "" _out_dir ${_def_dir}) -SET(_out_base "${_global_binary_dir}${_out_dir}") -SET(_out_header "${_out_base}/${_def_name}.h") -SET(_lib_name "${prefix}${_def_name}") -SET(_input_extra_code "${_global_source_dir}${_out_dir}/${_def_name}_extra.cxx") + +### -- Configure inputs to be cmake-path compatible +SET(_src_dir ${CMAKE_CURRENT_SOURCE_DIR}) +SET(_bin_dir ${CMAKE_CURRENT_BINARY_DIR}) +SET(_def_file "${_src_dir}/${def_file}") ## -- Infere source code filenames MATH(EXPR _last_range "${number_of_files}-1") -SET(_out_code) +SET(_out_code "${_bin_dir}/${out_lib_name}.h") FOREACH(_n RANGE 0 ${_last_range}) - LIST(APPEND _out_code ${_out_base}/${_def_name}_${_n}.cxx) + LIST(APPEND _out_code ${_bin_dir}/${out_lib_name}_${_n}.cxx) ENDFOREACH(_n) -## -- Add extra code, if any -SET(_all_out_code ${_out_code}) -IF(EXISTS ${_input_extra_code}) - LIST(APPEND _all_out_code ${_input_extra_code}) -ENDIF(EXISTS ${_input_extra_code}) - ## -- Command to write source code ADD_CUSTOM_COMMAND( - OUTPUT ${_out_header} ${_out_code} - DEPENDS ${cpPlugins_bash_BuildInstances_APP} ${_def_file} - COMMAND ${cpPlugins_bash_BuildInstances_APP} ${_def_file} ${_lib_name} ${_out_base}/${_def_name} ${number_of_files} + OUTPUT ${_out_code} + DEPENDS ${cpPlugins_bash_CreateInstances_APP} ${_def_file} + COMMAND ${cpPlugins_bash_CreateInstances_APP} ${_def_file} ${out_lib_name} ${_bin_dir} ${number_of_files} ) ## -- Create library -CreateLib( - "${_lib_name}" ${lib_dir} SHARED - "${_all_out_code}" "${_out_header}" "" - "${version}" "${short_version}" - ) - -## -- Return value -SET(${out_lib_name} ${_lib_name} PARENT_SCOPE) +CreateLib(${out_lib_name} SHARED "${_out_code}") ENDFUNCTION() ## ------------------------------------------------------------------------- -FUNCTION(Wrap_cpPlugins output_lib source_dir version short_version prefix) - -## -- Configure inputs to be cmake-path compatible -NormPaths(_source_dir ${source_dir}) -NormPaths(_global_source_dir ${PROJECT_SOURCE_DIR}) -NormPaths(_global_binary_dir ${PROJECT_BINARY_DIR}) -STRING(REPLACE "${_global_source_dir}" "" _out_dir ${_source_dir}) -SET(_out_dir "${_global_binary_dir}${_out_dir}") -FILE(MAKE_DIRECTORY ${_out_dir}) -GET_FILENAME_COMPONENT(_lib_name ${_source_dir} NAME_WE) -SET(_lib_name ${prefix}${_lib_name}) - -## -- Get source code -FILE(GLOB_RECURSE _hdr_h "${_source_dir}/*.h") -FILE(GLOB_RECURSE _hdr_hxx "${_source_dir}/*.hxx") -FILE(GLOB_RECURSE _hdr_hpp "${_source_dir}/*.hpp") -FILE(GLOB_RECURSE _src_c "${_source_dir}/*.c") -FILE(GLOB_RECURSE _src_cxx "${_source_dir}/*.cxx") -FILE(GLOB_RECURSE _src_cpp "${_source_dir}/*.cpp") -FILE(GLOB_RECURSE _qt_ui "${_source_dir}/*.ui") +FUNCTION( + CreatePlugin + lib_name + lib_dir + number_of_files + ) -## -- Identify sources to wrap +GET_FILENAME_COMPONENT(_lib_dir ${lib_dir} REALPATH) +FILE(GLOB_RECURSE _files "${_lib_dir}/*") SET(_hdr_to_wrap) -FOREACH(_h ${_hdr_h}) - FILE(READ ${_h} _txt) +SET(_instances) +FOREACH(_file ${_files}) + FILE(READ ${_file} _txt) STRING(FIND "${_txt}" "cpPluginsObject" _res) IF(NOT ${_res} EQUAL -1) - LIST(APPEND _hdr_to_wrap ${_h}) + LIST(APPEND _hdr_to_wrap ${_file}) ENDIF(NOT ${_res} EQUAL -1) -ENDFOREACH(_h) - -## -- Integrate all source files -SET(_all_src ${_src_c} ${_src_cpp} ${_src_cxx}) -SET(_all_hdr ${_hdr_h} ${_hdr_hpp} ${_hdr_hxx}) + GET_FILENAME_COMPONENT(_ext ${_file} EXT) + IF(${_ext} STREQUAL ".i") + LIST(APPEND _instances ${_file}) + ENDIF(${_ext} STREQUAL ".i") +ENDFOREACH(_file) + +IF(_instances) + FOREACH(_instance ${_instances}) + STRING( + REPLACE + ${PROJECT_SOURCE_DIR} + ${PROJECT_BINARY_DIR} + _out_dir + ${_lib_dir} + ) + MATH(EXPR _last_range "${number_of_files}-1") + SET(_out_code "${_out_dir}/${lib_name}.h") + FOREACH(_n RANGE 0 ${_last_range}) + LIST(APPEND _out_code ${_out_dir}/${lib_name}_${_n}.cxx) + ENDFOREACH(_n) + + ADD_CUSTOM_COMMAND( + OUTPUT ${_out_code} + DEPENDS ${cpPlugins_bash_CreateInstances_APP} ${_instance} + COMMAND ${CMAKE_COMMAND} -E make_directory ${_out_dir} + COMMAND ${cpPlugins_bash_CreateInstances_APP} ${_instance} ${lib_name} ${_out_dir} ${number_of_files} + ) + LIST(APPEND _files ${_out_code}) + ENDFOREACH(_instance) +ENDIF(_instances) -## -- Wrap plugins IF(_hdr_to_wrap) - SET(_host ${_out_dir}/${_lib_name}_host.cxx) + STRING( + REPLACE + ${PROJECT_SOURCE_DIR} + ${PROJECT_BINARY_DIR} + _out_dir + ${_lib_dir} + ) + SET(_host ${_out_dir}/${lib_name}_host.cxx) ADD_CUSTOM_COMMAND( OUTPUT ${_host} DEPENDS ${cpPlugins_bash_HostCreator_APP} ${_hdr_to_wrap} - COMMAND ${cpPlugins_bash_HostCreator_APP} ${_lib_name} ${_host} ${_hdr_to_wrap} + COMMAND ${CMAKE_COMMAND} -E make_directory ${_out_dir} + COMMAND ${cpPlugins_bash_HostCreator_APP} ${lib_name} ${_host} ${_hdr_to_wrap} ) - SET(_all_src ${_all_src} ${_host}) + LIST(APPEND _files ${_host}) ENDIF(_hdr_to_wrap) -## -- Ok, build library -IF(_all_src) - CreateLib( - ${_lib_name} leo SHARED - "${_all_src}" "${_all_hdr}" "${_qt_ui}" - "${version}" "${short_version}" - ${ARGN} - ) - SET(${output_lib} ${_lib_name} PARENT_SCOPE) -ELSE(_all_src) - MESSAGE(FATAL_ERROR "No source code found to build \"${_lib_name}\"") -ENDIF(_all_src) +CreateLib(${lib_name} SHARED ${_files}) + ENDFUNCTION() ## ------------------------------------------------------------------------- -FUNCTION(AppFromDir output_app source_dir) - -## -- Configure inputs to be cmake-path compatible -NormPaths(_global_source_dir ${PROJECT_SOURCE_DIR}) -NormPaths(_global_binary_dir ${PROJECT_BINARY_DIR}) -NormPaths(_source_dir ${source_dir}) -STRING(REPLACE "${_global_source_dir}" "" _local_source_dir ${_source_dir}) -SET(_binary_dir ${_global_binary_dir}${_local_source_dir}) -IF(${output_app}) - SET(_app_name ${${output_app}}) -ELSE(${output_app}) - GET_FILENAME_COMPONENT(_app_name ${_source_dir} NAME_WE) -ENDIF(${output_app}) -SET(_app_name_option OFF) -IF(ARGN) - LIST(GET ARGN 0 _app_name_option) -ENDIF(ARGN) -OPTION( - BUILD_${_app_name} - "Build \"${_app_name}\" application" - ${_app_name_option} +FUNCTION( + CompileAppFromDir + app_name + app_dir ) - -## -- Real build commands -IF(BUILD_${_app_name}) - ## -- Some useful variables - SET(_sources_extensions .c .cpp .cxx) - SET(_headers_extensions .h .hpp .hxx) - SET(_qt_ui_extensions .ui) - SET(_dirs ${_source_dir} ${_binary_dir}) - SET(_sources) - SET(_headers) - SET(_qt_uis) - - ## -- Glob source code - FOREACH(_d ${_dirs}) - FOREACH(_e ${_sources_extensions}) - FILE(GLOB_RECURSE _f "${_d}/*${_e}") - SET(_sources ${_sources} ${_f}) - ENDFOREACH(_e) - FOREACH(_e ${_headers_extensions}) - FILE(GLOB_RECURSE _f "${_d}/*${_e}") - SET(_headers ${_headers} ${_f}) - ENDFOREACH(_e) - FOREACH(_e ${_qt_ui_extensions}) - FILE(GLOB_RECURSE _f "${_d}/*${_e}") - SET(_qt_uis ${_qt_uis} ${_f}) - ENDFOREACH(_e) - ENDFOREACH(_d) - - ## -- Configure some files - FILE(GLOB_RECURSE _configs "${_source_dir}/*.in") - FOREACH(_c ${_configs}) - - ## -- Build input and output names - NormPaths(_input_file ${_c}) - GET_FILENAME_COMPONENT(_input_name ${_input_file} NAME) - GET_FILENAME_COMPONENT(_input_dir ${_input_file} DIRECTORY) - STRING(REPLACE ".in" "" _output_name ${_input_name}) - STRING(REPLACE "${_global_source_dir}" "" _output_dir ${_input_dir}) - SET(_output_file "${_global_binary_dir}${_output_dir}/${_output_name}") - - ## -- Configure file - CONFIGURE_FILE(${_input_file} ${_output_file} @ONLY) - - ## -- Add it to the correct list - GET_FILENAME_COMPONENT(_output_ext ${_output_name} EXT) - IF( - "${_output_ext}" STREQUAL ".h" - OR - "${_output_ext}" STREQUAL ".hpp" - OR - "${_output_ext}" STREQUAL ".hxx" - ) - SET(_headers ${_headers}) - ENDIF() - IF( - "${_output_ext}" STREQUAL ".c" - OR - "${_output_ext}" STREQUAL ".cpp" - OR - "${_output_ext}" STREQUAL ".cxx" - ) - SET(_sources ${_sources}) - ENDIF() - IF("${_output_ext}" STREQUAL ".ui") - SET(_qt_uis ${_qt_uis}) - ENDIF() - ENDFOREACH(_c) - - # -- Prepare Qt4-based code - IF(Qt4_FOUND) - - ## -- Guess what headers sould be qt-moc'ed - Wrap_Qt_CPP(_qt_moc_sources ${_headers}) - IF(_qt_moc_sources) - SET(_sources ${_sources} ${_qt_moc_sources}) - ENDIF(_qt_moc_sources) - ## -- Guess what qt-ui's sould be qt-uic'ed - ## -- Wrap qt-ui headers: this is equivalent to QT4_WRAP_UI except to - ## -- change the output file - Wrap_Qt_UI(_qt_ui_headers ${_qt_uis}) - IF(_qt_ui_headers) - SET(_headers ${_headers} ${_qt_ui_headers}) - SET(_sources ${_sources} ${_qt_ui_headers}) - ENDIF(_qt_ui_headers) - ENDIF(Qt4_FOUND) - - ## -- Ok, compile application - IF(_sources) - SET(_gui_type "") - IF(WIN32) - SET(_gui_type WIN32) - ENDIF(WIN32) - IF(APPLE) - SET(_gui_type MACOSX_BUNDLE) - ENDIF(APPLE) - ADD_EXECUTABLE(${_app_name} ${_gui_type} ${_sources}) - SET(${output_app} ${_app_name} PARENT_SCOPE) - ELSE(_sources) - SET(${output_app} "" PARENT_SCOPE) - MESSAGE(FATAL_ERROR "No source code found to build \"${_app_name}\"") - ENDIF(_sources) -ENDIF(BUILD_${_app_name}) - +FILE(GLOB_RECURSE _files "${app_dir}/*") +PrepareSourceFiles(_srcs _hdrs _paths ${_files} ${ARGN}) +INCLUDE_DIRECTORIES( + ${_paths} + ${CMAKE_CURRENT_SOURCE_DIR} + ${CMAKE_CURRENT_BINARY_DIR} + ) +IF(_srcs) + SET(_app_os_target) + IF(${CMAKE_SYSTEM_NAME} STREQUAL "Windows") + SET(_app_os_target WIN32) + ELSEIF(${CMAKE_SYSTEM_NAME} STREQUAL "Darwin") + SET(_app_os_target MACOSX_BUNDLE) + ENDIF(${CMAKE_SYSTEM_NAME} STREQUAL "Windows") + ADD_EXECUTABLE(${app_name} ${_app_os_target} ${_srcs} ${_hdrs}) +ENDIF(_srcs) ENDFUNCTION() ## eof - $RCSfile$ diff --git a/cmake/Options.cmake b/cmake/Options.cmake index 63990d9..0d477c0 100644 --- a/cmake/Options.cmake +++ b/cmake/Options.cmake @@ -2,12 +2,5 @@ ## == Some configurable options == ## =============================== -OPTION(USE_cpPlugins "Build cpPlugins-based code" OFF) -IF(USE_cpPlugins) - FIND_PACKAGE(cpPlugins REQUIRED) - IF(USE_QT4) - INCLUDE(cmake/Qt4Tools.cmake) - ENDIF(USE_QT4) -ENDIF(USE_cpPlugins) ## eof - $RCSfile$ diff --git a/cmake/Qt4Tools.cmake b/cmake/QtTools.cmake similarity index 54% rename from cmake/Qt4Tools.cmake rename to cmake/QtTools.cmake index 16a0103..a49b3d5 100644 --- a/cmake/Qt4Tools.cmake +++ b/cmake/QtTools.cmake @@ -6,6 +6,17 @@ SET(QT4_FOUND "0") IF(USE_QT4) FIND_PACKAGE(Qt4 REQUIRED) INCLUDE(${QT_USE_FILE}) + SET( + _modules + vtkGUISupportQt + vtkGUISupportQtOpenGL + ) + FOREACH(_m ${_modules}) + IF(NOT ${_m}_LOADED) + MESSAGE(FATAL_ERROR "${_m} module is required but not available.") + BREAK() + ENDIF(NOT ${_m}_LOADED) + ENDFOREACH(_m) SET(QT4_FOUND "1") ENDIF(USE_QT4) diff --git a/lib/CMakeLists.txt b/lib/CMakeLists.txt index efe40ca..c3d3e5d 100644 --- a/lib/CMakeLists.txt +++ b/lib/CMakeLists.txt @@ -2,13 +2,7 @@ ## == Build a library from a directory == ## ====================================== -LibFromDir( - fpa - ${PROJECT_BINARY_DIR}/lib - SHARED - ${CMAKE_CURRENT_SOURCE_DIR}/fpa - "${prj_VERSION}" "${prj_SHORT_VERSION}" - ) +CompileLibFromDir(fpa SHARED ${CMAKE_CURRENT_SOURCE_DIR}/fpa) ## =================================== ## == Build instances for cpPlugins == diff --git a/lib/Instances/CMakeLists.txt b/lib/Instances/CMakeLists.txt index 0c44d02..efcdf87 100644 --- a/lib/Instances/CMakeLists.txt +++ b/lib/Instances/CMakeLists.txt @@ -1,52 +1,24 @@ ## =========================== ## == Compile each instance == ## =========================== +SET( + _all_defs + DataObjects + Filters + ) -FILE(GLOB _instances "${CMAKE_CURRENT_SOURCE_DIR}/*.i") -SET(_all_instances) -FOREACH(_instance ${_instances}) +SET(_all_libs) +FOREACH(_def ${_all_defs}) CompileInstances( - _lib_name - ${PROJECT_BINARY_DIR}/lib - ${_instance} ${cpPlugins_NUMBER_OF_FILES} - "" "${prj_VERSION}" "${prj_SHORT_VERSION}" + fpaInstances_${_def} + fpa_${_def}.i + ${cpPlugins_CONFIG_NUMBER_OF_FILES} ) - LIST(APPEND _all_instances ${_lib_name}) -ENDFOREACH(_instance) + LIST(APPEND _all_libs cpInstances_${_def}) +ENDFOREACH(_def) SET( - fpa_Instances ${_all_instances} + fpa_Instances ${_all_libs} CACHE INTERNAL "All valid instances." FORCE ) -## =========== -## == Links == -## =========== - -TARGET_LINK_LIBRARIES( - fpa_DataObjects - ${ITK_LIBRARIES} ${VTK_LIBRARIES} - ${cpPlugins_BaseObjects_LIB} - ${cpPlugins_Images_LIB} ${cpPlugins_Paths_LIB} - ) -TARGET_LINK_LIBRARIES( - fpa_Filters - fpa_DataObjects - ${cpPlugins_ImageFilters_LIB} - ) - -## =================================== -## == Libraries to dynamically load == -## =================================== - -SET(fpa_DynLibs) -FOREACH(_lib ${fpa_Instances}) - LIST(APPEND fpa_DynLibs "${CMAKE_INSTALL_PREFIX}/bin|${_lib}") - LIST(APPEND fpa_DynLibs "${CMAKE_INSTALL_PREFIX}/lib|${_lib}") - LIST(APPEND fpa_DynLibs "${LIBRARY_OUTPUT_PATH}|${_lib}") -ENDFOREACH(_lib) -FILE(WRITE ${PROJECT_BINARY_DIR}/cpPlugins_Libraries.config "") -FOREACH(_lib ${fpa_DynLibs}) - FILE(APPEND ${PROJECT_BINARY_DIR}/cpPlugins_Libraries.config "${_lib}\n") -ENDFOREACH(_lib) - ## eof - $RCSfile$ diff --git a/lib/Instances/fpa_DataObjects.i b/lib/Instances/fpa_DataObjects.i index 62280ab..79f449d 100644 --- a/lib/Instances/fpa_DataObjects.i +++ b/lib/Instances/fpa_DataObjects.i @@ -1,13 +1,13 @@ +header #define ITK_MANUAL_INSTANTIATION -i cpPlugins_Paths.h -t fpa/Image/Functors/SimpleNeighborhood -t fpa/Image/Functors/SimpleDijkstraCost -t fpa/Image/MinimumSpanningTree -t fpa/Base/MinimumSpanningTree +tinclude fpa/Image/Functors/SimpleNeighborhood:h|hxx +tinclude fpa/Image/Functors/SimpleDijkstraCost:h|hxx +tinclude fpa/Image/MinimumSpanningTree:h|hxx +tinclude fpa/Base/MinimumSpanningTree:h|hxx -c fpa::Image::Functors::SimpleNeighborhood< itk::ImageBase< #process_dims# > > -c fpa::Image::Functors::SimpleDijkstraCost< itk::Image< #pixels#, #process_dims# >, #reals# > -c fpa::Base::MinimumSpanningTree< itk::Index< #process_dims# >, cpExtensions::DataStructures::PolyLineParametricPath< #process_dims# >, itk::Image< itk::Offset< #process_dims# >, #process_dims# > > -c fpa::Image::MinimumSpanningTree< #process_dims# > +instances fpa::Image::Functors::SimpleNeighborhood< itk::ImageBase< #process_dims# > > +instances fpa::Image::Functors::SimpleDijkstraCost< itk::Image< #scalar_pixels#, #process_dims# >, #reals# > +instances fpa::Base::MinimumSpanningTree< itk::Index< #process_dims# >, cpExtensions::DataStructures::PolyLineParametricPath< #process_dims# >, itk::Image< itk::Offset< #process_dims# >, #process_dims# > > +instances fpa::Image::MinimumSpanningTree< #process_dims# > ** eof - $RCSfile$ diff --git a/lib/fpa/Image/Functors/Base.h b/lib/fpa/Image/Functors/Base.h index 607b7c3..622cc0a 100644 --- a/lib/fpa/Image/Functors/Base.h +++ b/lib/fpa/Image/Functors/Base.h @@ -3,6 +3,7 @@ #include #include +#include namespace fpa {