From d069d4ce8d814abaa6217859158bad97ad3fb09c Mon Sep 17 00:00:00 2001 From: Bryn Lloyd Date: Tue, 9 Oct 2018 12:12:26 +0200 Subject: [PATCH 1/5] added install target for building proper MACOS bundle --- CMake/CommonMacros.cmake | 31 +++++++++++++++++++++++++++++++ CMake/ThirdPartyBoost.cmake | 2 +- iSeg/CMakeLists.txt | 28 ++++++++++++++++------------ 3 files changed, 48 insertions(+), 13 deletions(-) diff --git a/CMake/CommonMacros.cmake b/CMake/CommonMacros.cmake index 294cfe8c..4c0815aa 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,34 @@ 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}) + + IF(APPLE) + SET(APP_BUNDLE_NAME "${app_name}.app") + SET(BUNDLE_INSTALL_TARGET ${CMAKE_INSTALL_PREFIX}) + SET(BUNDLE_INSTALL_DIRECTORY ${BUNDLE_INSTALL_TARGET}/${APP_BUNDLE_NAME}/Contents/MacOS) + LIST(APPEND BUNDLE_APPS ${BUNDLE_INSTALL_TARGET}/${APP_BUNDLE_NAME}) + ELSE() + 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) + message(STATUS \"BUNDLE_APPS ${BUNDLE_APPS}\") + fixup_bundle(\"${BUNDLE_APPS}\" \"${BUNDLE_LIBRARIES}\" \"${BUNDLE_SEARCH_DIRS}\") + " COMPONENT Runtime) ENDMACRO() \ No newline at end of file diff --git a/CMake/ThirdPartyBoost.cmake b/CMake/ThirdPartyBoost.cmake index dc02b1d1..8d929eec 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.63 REQUIRED COMPONENTS filesystem thread log unit_test_framework program_options date_time random chrono locale timer ${BOOST_REQUIRED_LIBS}) if(NOT Boost_FOUND) message(FATAL_ERROR "Boost library not found!") endif(NOT Boost_FOUND) diff --git a/iSeg/CMakeLists.txt b/iSeg/CMakeLists.txt index 4b4d9d48..d668fd6f 100755 --- a/iSeg/CMakeLists.txt +++ b/iSeg/CMakeLists.txt @@ -205,18 +205,22 @@ 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} + 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() From 697e5ad96f4219c25152459aaeaa7f21175e18e4 Mon Sep 17 00:00:00 2001 From: Bryn Lloyd Date: Tue, 9 Oct 2018 13:07:49 +0200 Subject: [PATCH 2/5] remove some unused boost libs --- CMake/ThirdPartyBoost.cmake | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/CMake/ThirdPartyBoost.cmake b/CMake/ThirdPartyBoost.cmake index 8d929eec..ab91bd14 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 timer ${BOOST_REQUIRED_LIBS}) +FIND_PACKAGE(Boost 1.67 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) From 9372d6530b855e04b488de8921f4366ab3aa5ddc Mon Sep 17 00:00:00 2001 From: Bryn Lloyd Date: Tue, 9 Oct 2018 13:17:07 +0200 Subject: [PATCH 3/5] remove unused code to copy dlls to build directory for non WIN32 platforms fix compile error (for some setups) related to boost::algorithm::split --- CMake/ThirdPartyBlosc.cmake | 7 ++----- CMake/ThirdPartyBoost.cmake | 14 ++------------ CMake/ThirdPartyHDF5.cmake | 12 +----------- CMake/ThirdPartyVTK.cmake | 12 +----------- .../AutoTubeWidget.cpp | 19 ++++++++++--------- 5 files changed, 16 insertions(+), 48 deletions(-) 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 ab91bd14..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.67 REQUIRED COMPONENTS filesystem thread unit_test_framework date_time random chrono timer ${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/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(); } From dbe170dd71d689cbf755ece26b294dbb9fcf0b4d Mon Sep 17 00:00:00 2001 From: Bryn Lloyd Date: Tue, 9 Oct 2018 13:31:50 +0200 Subject: [PATCH 4/5] trying to make bundle stuff work also on windows --- CMake/CommonMacros.cmake | 7 ++++--- iSeg/CMakeLists.txt | 1 + 2 files changed, 5 insertions(+), 3 deletions(-) diff --git a/CMake/CommonMacros.cmake b/CMake/CommonMacros.cmake index 4c0815aa..f366bd82 100755 --- a/CMake/CommonMacros.cmake +++ b/CMake/CommonMacros.cmake @@ -80,13 +80,15 @@ MACRO(INIT_BUNDLE app_name) 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_TARGET ${CMAKE_INSTALL_PREFIX}) SET(BUNDLE_INSTALL_DIRECTORY ${BUNDLE_INSTALL_TARGET}/${APP_BUNDLE_NAME}/Contents/MacOS) LIST(APPEND BUNDLE_APPS ${BUNDLE_INSTALL_TARGET}/${APP_BUNDLE_NAME}) ELSE() - LIST(APPEND BUNDLE_APPS "${CMAKE_INSTALL_PREFIX}/${app_name}") + 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() @@ -100,7 +102,6 @@ MACRO(INSTALL_BUNDLE) INSTALL(CODE " include(BundleUtilities) set(BU_CHMOD_BUNDLE_ITEMS 1) - message(STATUS \"BUNDLE_APPS ${BUNDLE_APPS}\") fixup_bundle(\"${BUNDLE_APPS}\" \"${BUNDLE_LIBRARIES}\" \"${BUNDLE_SEARCH_DIRS}\") " COMPONENT Runtime) ENDMACRO() \ No newline at end of file diff --git a/iSeg/CMakeLists.txt b/iSeg/CMakeLists.txt index d668fd6f..298277b7 100755 --- a/iSeg/CMakeLists.txt +++ b/iSeg/CMakeLists.txt @@ -210,6 +210,7 @@ IF(APPLE) INSTALL(TARGETS iSeg BUNDLE DESTINATION ${BUNDLE_INSTALL_TARGET} + RUNTIME DESTINATION ${BUNDLE_INSTALL_TARGET} COMPONENT executable ) From 345e122ec201966c49c488f0631ef74962d9a7a3 Mon Sep 17 00:00:00 2001 From: Bryn Lloyd Date: Tue, 9 Oct 2018 13:39:33 +0200 Subject: [PATCH 5/5] upgrade cmake requirement because of policy code in ThirdPartyHDF5.cmake --- CMakeLists.txt | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) 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)