diff --git a/CMake/CommonMacros.cmake b/CMake/CommonMacros.cmake index 294cfe8c..f366bd82 100755 --- a/CMake/CommonMacros.cmake +++ b/CMake/CommonMacros.cmake @@ -54,6 +54,7 @@ MACRO(MSVC_SOURCE_GROUP filter_name) SOURCE_GROUP( ${filter_name} FILES ${ARGN} ) ENDIF() ENDMACRO() + # # Visual studio specific: add files of a project to a specific filter filter_name # @@ -72,4 +73,35 @@ MACRO(SUBDIR_LIST result curdir) ENDIF() ENDFOREACH() SET(${result} ${dirlist}) +ENDMACRO() + +MACRO(INIT_BUNDLE app_name) + SET(BUNDLE_APPS) + SET(BUNDLE_LIBRARIES) + SET(BUNDLE_SEARCH_DIRS ${CMAKE_INSTALL_PREFIX} ${CMAKE_LIBRARY_OUTPUT_DIRECTORY}) + + SET(BUNDLE_INSTALL_TARGET ${CMAKE_INSTALL_PREFIX}) + IF(APPLE) + SET(APP_BUNDLE_NAME "${app_name}.app") + SET(BUNDLE_INSTALL_DIRECTORY ${BUNDLE_INSTALL_TARGET}/${APP_BUNDLE_NAME}/Contents/MacOS) + LIST(APPEND BUNDLE_APPS ${BUNDLE_INSTALL_TARGET}/${APP_BUNDLE_NAME}) + ELSE() + SET(APP_BUNDLE_NAME ${app_name}) + SET(BUNDLE_INSTALL_DIRECTORY ${CMAKE_INSTALL_PREFIX}) + LIST(APPEND BUNDLE_APPS ${CMAKE_INSTALL_PREFIX}/${app_name}) + ENDIF(APPLE) +ENDMACRO() + +# +# Note about BundleUtilities: +# +# the libs passed as the second argument to fixup_bundle MUST already be copied into the app bundle. +# fixup_bundle only copies dependencies it discovers. Any libs passed as the second argument will +# also have their dependencies copied in and fixed. +MACRO(INSTALL_BUNDLE) + INSTALL(CODE " + include(BundleUtilities) + set(BU_CHMOD_BUNDLE_ITEMS 1) + fixup_bundle(\"${BUNDLE_APPS}\" \"${BUNDLE_LIBRARIES}\" \"${BUNDLE_SEARCH_DIRS}\") + " COMPONENT Runtime) ENDMACRO() \ No newline at end of file diff --git a/CMake/ThirdPartyBlosc.cmake b/CMake/ThirdPartyBlosc.cmake index 106069ca..f1d49f87 100755 --- a/CMake/ThirdPartyBlosc.cmake +++ b/CMake/ThirdPartyBlosc.cmake @@ -35,10 +35,7 @@ ENDMACRO() MACRO(INSTALL_RUNTIME_LIBRARIES_BLOSC) MESSAGE( STATUS "--> ThirdPartyBlosc: installing BLOSC library ..." ) - IF(APPLE) - #FILE(COPY ${BLOSC_ROOT}/lib/ - # DESTINATION ${CMAKE_RUNTIME_OUTPUT_DIRECTORY} - # FILES_MATCHING PATTERN "lib*.dylib*") - ELSE() + IF(MSVC) + # anything to copy? ENDIF() ENDMACRO() \ No newline at end of file diff --git a/CMake/ThirdPartyBoost.cmake b/CMake/ThirdPartyBoost.cmake index dc02b1d1..20ec8453 100755 --- a/CMake/ThirdPartyBoost.cmake +++ b/CMake/ThirdPartyBoost.cmake @@ -15,7 +15,7 @@ endif(BOOST_ROOT STREQUAL "not defined") #set(Boost_DEBUG on) #set(Boost_DETAILED_FAILURE_MSG on) set(Boost_USE_MULTITHREADED on) -FIND_PACKAGE(Boost 1.63 REQUIRED COMPONENTS filesystem thread log unit_test_framework program_options date_time random chrono locale ${BOOST_REQUIRED_LIBS}) +FIND_PACKAGE(Boost 1.64 REQUIRED COMPONENTS filesystem thread unit_test_framework date_time random chrono timer ${BOOST_REQUIRED_LIBS}) if(NOT Boost_FOUND) message(FATAL_ERROR "Boost library not found!") endif(NOT Boost_FOUND) @@ -36,17 +36,7 @@ ENDMACRO() MACRO(INSTALL_RUNTIME_LIBRARIES_BOOST) MESSAGE( STATUS "--> ThirdPartyBoost: installing boost library ..." ) - IF(CMAKE_COMPILER_IS_GNUCXX) - IF(APPLE) - FILE(COPY ${BOOST_LIBRARY_DIR}/ - DESTINATION ${CMAKE_RUNTIME_OUTPUT_DIRECTORY} - FILES_MATCHING PATTERN "*.dylib") - ELSE() - FILE(COPY ${BOOST_LIBRARY_DIR}/ - DESTINATION ${CMAKE_RUNTIME_OUTPUT_DIRECTORY} - FILES_MATCHING PATTERN "*${BOOST_VERSION}.so*" ) - ENDIF() - ELSEIF(MSVC) + IF(MSVC) FOREACH(BUILD_TYPE ${CMAKE_CONFIGURATION_TYPES}) STRING(TOLOWER ${BUILD_TYPE} build_type) IF(${build_type} MATCHES rel*) diff --git a/CMake/ThirdPartyHDF5.cmake b/CMake/ThirdPartyHDF5.cmake index 097a14a5..cb7d5946 100755 --- a/CMake/ThirdPartyHDF5.cmake +++ b/CMake/ThirdPartyHDF5.cmake @@ -26,17 +26,7 @@ ENDMACRO() MACRO(INSTALL_RUNTIME_LIBRARIES_HDF5) MESSAGE( STATUS "--> ThirdPartyHdf5: installing HDF5 library ..." ) - IF(CMAKE_COMPILER_IS_GNUCXX) - IF(APPLE) - FILE(COPY ${HDF5_LIBRARY_DIR}/ - DESTINATION ${CMAKE_RUNTIME_OUTPUT_DIRECTORY} - FILES_MATCHING PATTERN "libhdf5*.dylib*") - ELSE() - FILE(COPY ${HDF5_LIBRARY_DIR}/ - DESTINATION ${CMAKE_RUNTIME_OUTPUT_DIRECTORY} - FILES_MATCHING PATTERN "libhdf5*.so" PATTERN "libhdf5*.so.*" ) - ENDIF() - ELSEIF(MSVC) + IF(MSVC) SET(MSVC_CONFIGURATION_TYPES ${CMAKE_CONFIGURATION_TYPES}) FOREACH(BUILD_TYPE ${MSVC_CONFIGURATION_TYPES}) FILE(COPY ${HDF5_INCLUDE_DIRS}/../bin/ diff --git a/CMake/ThirdPartyVTK.cmake b/CMake/ThirdPartyVTK.cmake index bfa45f9a..62b50c54 100755 --- a/CMake/ThirdPartyVTK.cmake +++ b/CMake/ThirdPartyVTK.cmake @@ -45,17 +45,7 @@ ENDMACRO() MACRO(INSTALL_RUNTIME_LIBRARIES_VTK) MESSAGE( STATUS "--> ThirdPartyVTK: installing VTK library ..." ) - IF(CMAKE_COMPILER_IS_GNUCXX) - IF(APPLE) - FILE(COPY ${VTK_LIBRARY_DIR}/ - DESTINATION ${CMAKE_RUNTIME_OUTPUT_DIRECTORY} - FILES_MATCHING PATTERN "*.dylib*") - ELSE() - FILE(COPY ${VTK_LIBRARY_DIR}/ - DESTINATION ${CMAKE_RUNTIME_OUTPUT_DIRECTORY} - FILES_MATCHING PATTERN "*.so") - ENDIF() - ELSE() + IF(MSVC) FOREACH(BUILD_TYPE ${CMAKE_CONFIGURATION_TYPES}) STRING(TOLOWER ${BUILD_TYPE} build_type) IF(${build_type} MATCHES rel*) diff --git a/CMakeLists.txt b/CMakeLists.txt index f4e1186b..7be28d31 100755 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -7,7 +7,7 @@ ## This software is released under the MIT License. ## https://opensource.org/licenses/MIT ## -CMAKE_MINIMUM_REQUIRED(VERSION 3.6) +CMAKE_MINIMUM_REQUIRED(VERSION 3.12) PROJECT(ISEG C CXX) SET(CMAKE_CONFIGURATION_TYPES "Debug;Release" CACHE STRING "Which Build Types to support" FORCE) diff --git a/Plugins/TracingTubularStructures/AutoTubeWidget.cpp b/Plugins/TracingTubularStructures/AutoTubeWidget.cpp index e9e50f8f..0d6a4b80 100644 --- a/Plugins/TracingTubularStructures/AutoTubeWidget.cpp +++ b/Plugins/TracingTubularStructures/AutoTubeWidget.cpp @@ -311,12 +311,13 @@ void AutoTubeWidget::do_work_nd(TInput* source, TTissue* tissues, TTarget* targe if (!_selected_objects->text().isEmpty()) { std::vector tokens; - boost::algorithm::split(tokens, _selected_objects->text().toStdString(), boost::algorithm::is_any_of(",")); + std::string selected_objects_text = _selected_objects->text().toStdString(); + boost::algorithm::split(tokens, selected_objects_text, boost::algorithm::is_any_of(",")); std::transform(tokens.begin(), tokens.end(), std::back_inserter(object_ids), - [](std::string s) { - boost::algorithm::trim(s); - return stoi(s); - }); + [](std::string s) { + boost::algorithm::trim(s); + return stoi(s); + }); } // mask feature image before skeletonization @@ -337,7 +338,7 @@ void AutoTubeWidget::do_work_nd(TInput* source, TTissue* tissues, TTarget* targe auto masker = itk::MaskImageFilter::New(); masker->SetInput(feature_image); masker->SetMaskImage(map_filter->GetOutput()); - SAFE_UPDATE(masker, return); + SAFE_UPDATE(masker, return ); feature_image = masker->GetOutput(); } @@ -364,7 +365,7 @@ void AutoTubeWidget::do_work_nd(TInput* source, TTissue* tissues, TTarget* targe auto threshold = threshold_filter_type::New(); threshold->SetInput(nonmax_filter->GetOutput()); threshold->SetLowerThreshold(std::nextafter(std::min(lower, 0.f), 1.f)); - SAFE_UPDATE(threshold, return); + SAFE_UPDATE(threshold, return ); skeleton = threshold->GetOutput(); } else @@ -372,7 +373,7 @@ void AutoTubeWidget::do_work_nd(TInput* source, TTissue* tissues, TTarget* targe auto threshold = threshold_filter_type::New(); threshold->SetInput(feature_image); threshold->SetLowerThreshold(lower); - SAFE_UPDATE(threshold, return); + SAFE_UPDATE(threshold, return ); skeleton = threshold->GetOutput(); } @@ -408,7 +409,7 @@ void AutoTubeWidget::do_work_nd(TInput* source, TTissue* tissues, TTarget* targe auto threshold = itk::BinaryThresholdImageFilter::New(); threshold->SetInput(relabel->GetOutput()); threshold->SetLowerThreshold(1); - SAFE_UPDATE(threshold, return); + SAFE_UPDATE(threshold, return ); output = threshold->GetOutput(); } diff --git a/iSeg/CMakeLists.txt b/iSeg/CMakeLists.txt index 4b4d9d48..298277b7 100755 --- a/iSeg/CMakeLists.txt +++ b/iSeg/CMakeLists.txt @@ -205,18 +205,23 @@ IF(ISEG_BUILD_PRECOMPILED_HEADER) ENDIF() ENDIF() - IF(APPLE) - # copy plugins to bundle - FOREACH(plugin ${PLUGIN_NAMES}) - LIST(APPEND PLUGIN_FILES ${CMAKE_RUNTIME_OUTPUT_DIRECTORY}/lib${plugin}.dylib) - ADD_DEPENDENCIES(iSeg ${plugin}) + INIT_BUNDLE(iSeg) + + INSTALL(TARGETS iSeg + BUNDLE DESTINATION ${BUNDLE_INSTALL_TARGET} + RUNTIME DESTINATION ${BUNDLE_INSTALL_TARGET} + COMPONENT executable + ) + + FILE(GLOB plugins ${CMAKE_LIBRARY_OUTPUT_DIRECTORY}/*.ext.*) + INSTALL(FILES ${plugins} DESTINATION ${BUNDLE_INSTALL_DIRECTORY}) + + FOREACH(lib ${plugins}) + GET_FILENAME_COMPONENT(libfile ${lib} NAME) + MESSAGE("Adding ${libfile} to bundle") + LIST(APPEND BUNDLE_LIBRARIES ${BUNDLE_INSTALL_DIRECTORY}/${libfile}) ENDFOREACH() - ADD_CUSTOM_COMMAND( - TARGET iSeg - POST_BUILD - COMMAND ${CMAKE_COMMAND} -E copy - ${PLUGIN_FILES} ${CMAKE_RUNTIME_OUTPUT_DIRECTORY}/iSeg.app/Contents/MacOS - ) -ENDIF() \ No newline at end of file + INSTALL_BUNDLE() +ENDIF()