Skip to content

Commit

Permalink
Merge pull request #60 from dyollb/fix/macos_bundle
Browse files Browse the repository at this point in the history
Fix/macos bundle
  • Loading branch information
dyollb authored Oct 9, 2018
2 parents 30598b7 + 345e122 commit 460d7a0
Show file tree
Hide file tree
Showing 8 changed files with 66 additions and 61 deletions.
32 changes: 32 additions & 0 deletions CMake/CommonMacros.cmake
Original file line number Diff line number Diff line change
Expand Up @@ -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
#
Expand All @@ -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()
7 changes: 2 additions & 5 deletions CMake/ThirdPartyBlosc.cmake
Original file line number Diff line number Diff line change
Expand Up @@ -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()
14 changes: 2 additions & 12 deletions CMake/ThirdPartyBoost.cmake
Original file line number Diff line number Diff line change
Expand Up @@ -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)
Expand All @@ -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*)
Expand Down
12 changes: 1 addition & 11 deletions CMake/ThirdPartyHDF5.cmake
Original file line number Diff line number Diff line change
Expand Up @@ -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/
Expand Down
12 changes: 1 addition & 11 deletions CMake/ThirdPartyVTK.cmake
Original file line number Diff line number Diff line change
Expand Up @@ -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*)
Expand Down
2 changes: 1 addition & 1 deletion CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -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)
Expand Down
19 changes: 10 additions & 9 deletions Plugins/TracingTubularStructures/AutoTubeWidget.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -311,12 +311,13 @@ void AutoTubeWidget::do_work_nd(TInput* source, TTissue* tissues, TTarget* targe
if (!_selected_objects->text().isEmpty())
{
std::vector<std::string> 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
Expand All @@ -337,7 +338,7 @@ void AutoTubeWidget::do_work_nd(TInput* source, TTissue* tissues, TTarget* targe
auto masker = itk::MaskImageFilter<real_type, mask_type>::New();
masker->SetInput(feature_image);
masker->SetMaskImage(map_filter->GetOutput());
SAFE_UPDATE(masker, return);
SAFE_UPDATE(masker, return );
feature_image = masker->GetOutput();
}

Expand All @@ -364,15 +365,15 @@ 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
{
auto threshold = threshold_filter_type::New();
threshold->SetInput(feature_image);
threshold->SetLowerThreshold(lower);
SAFE_UPDATE(threshold, return);
SAFE_UPDATE(threshold, return );
skeleton = threshold->GetOutput();
}

Expand Down Expand Up @@ -408,7 +409,7 @@ void AutoTubeWidget::do_work_nd(TInput* source, TTissue* tissues, TTarget* targe
auto threshold = itk::BinaryThresholdImageFilter<labelfield_type, mask_type>::New();
threshold->SetInput(relabel->GetOutput());
threshold->SetLowerThreshold(1);
SAFE_UPDATE(threshold, return);
SAFE_UPDATE(threshold, return );
output = threshold->GetOutput();
}

Expand Down
29 changes: 17 additions & 12 deletions iSeg/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -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()
INSTALL_BUNDLE()
ENDIF()

0 comments on commit 460d7a0

Please sign in to comment.