Commit abdde218 authored by jcfr's avatar jcfr

BUG: Fix extension bundling and simplify mechanism used to specify the main application

1) In Applications/SlicerApp/CMakeLists.txt:

  Improve comment explaining what should be considered when adding an other
application into Applications folder.

  Given the fact Slicer_APPLICATION_NAME is used locally, minimize confusion
by renaming variable renaming it into SlicerApp_APPLICATION_NAME.

  In case the application being configured is the *Main* application,
explicitly compare "PROJECT_NAME" with "Slicer_MAIN_PROJECT".


2) Rename variable Slicer_APPLICATION_NAME used to identified the main
application into Slicer_MAIN_PROJECT_APPLICATION_NAME. This will
minimize confusion and help maintaining the code.

3) Let's note that the mechanism used to fixup application should probably
be extended to account for other application build in the Applications folder.

4) In top-level CMakeLists, move code specific to main application description
into its own section.

5) Configure variable "Slicer_MAIN_PROJECT" and "Slicer_MAIN_PROJECT_APPLICATION_NAME"
into SlicerConfig so that "SlicerExtensionCPackBundleFixup" could successfully
refer to Slicer_MAIN_PROJECT_APPLICATION_NAME. This closes #2130

See http://www.na-mic.org/Bug/view.php?id=2130

git-svn-id: http://svn.slicer.org/Slicer4/trunk@20272 3bd1e089-480b-0410-8dfb-8563597acbee
parent c724e144
project(SlicerApp)
# --------------------------------------------------------------------------
# It's possible to build more than one applications (i.e. an application "OtherApp"
# in addition to "Slicer").
#
# In that specific case, it's required to differentiate the two applications
# and specify which one should be considered as the *Main* one.
#
# This is usually done within the top level CMakeLists.txt file by setting the variable
# Slicer_MAIN_PROJECT.
#
# Within the Applications/OtherApp/CMakeLists.txt of the secondary application,
# the project name should be updated, the variable 'SlicerApp_APPLICATION_NAME'
# could also be optionnally set to a custom value.
#
# set(SlicerApp_APPLICATION_NAME ${PROJECT_NAME}) # Uncomment and optionnally set this variable using a custom value.
if(${PROJECT_NAME} STREQUAL ${Slicer_MAIN_PROJECT})
set(SlicerApp_APPLICATION_NAME ${Slicer_MAIN_PROJECT_APPLICATION_NAME})
endif()
# --------------------------------------------------------------------------
# Build option(s)
# --------------------------------------------------------------------------
......@@ -9,17 +30,6 @@ if(WIN32)
set(Slicer_HAS_CONSOLE_IO_SUPPORT ${Slicer_BUILD_WIN32_CONSOLE})
endif()
# It's possible to build more than one applications
# (i.e. an application SlicerDaemon in addition to SlicerApp), in that specific case,
# it's required to differentiate the two applications and
# specify which one should be considered as the *Main* one.
# The *Main* application is specified using the associated project name.
# This is usually done within the top level CMakeLists.txt file by setting the variable Slicer_MAIN_PROJECT.
# set(Slicer_APPLICATION_NAME SlicerDaemon)
if(DEFINED ${PROJECT_NAME}_APPLICATION_NAME)
set(Slicer_APPLICATION_NAME ${${PROJECT_NAME}_APPLICATION_NAME})
endif()
# --------------------------------------------------------------------------
# Sources
# --------------------------------------------------------------------------
......@@ -97,7 +107,7 @@ target_link_libraries(${KIT_LIBRARY_NAME}
# Configure Application Bundle Resources (Mac Only)
# --------------------------------------------------------------------------
if(Q_WS_MAC)
set(apple_icon_file ${Slicer_APPLICATION_NAME}.icns)
set(apple_icon_file ${SlicerApp_APPLICATION_NAME}.icns)
set(apple_bundle_sources "${CMAKE_CURRENT_SOURCE_DIR}/Resources/${apple_icon_file}")
set_source_files_properties(
"${apple_bundle_sources}"
......@@ -166,7 +176,7 @@ add_executable(${PROJECT_NAME}${SlicerApp_EXE_SUFFIX}
set_target_properties(${PROJECT_NAME}${SlicerApp_EXE_SUFFIX} PROPERTIES LABELS ${PROJECT_NAME})
if(APPLE)
set_target_properties(${PROJECT_NAME}${SlicerApp_EXE_SUFFIX} PROPERTIES OUTPUT_NAME ${Slicer_APPLICATION_NAME})
set_target_properties(${PROJECT_NAME}${SlicerApp_EXE_SUFFIX} PROPERTIES OUTPUT_NAME ${SlicerApp_APPLICATION_NAME})
endif()
target_link_libraries(${PROJECT_NAME}${SlicerApp_EXE_SUFFIX}
......@@ -201,11 +211,9 @@ install(TARGETS ${PROJECT_NAME}${SlicerApp_EXE_SUFFIX}
COMPONENT Runtime)
# --------------------------------------------------------------------------
# Configure Slicer Launcher
# Configure Slicer Launcher (Only for main application)
# --------------------------------------------------------------------------
# ${PROJECT_NAME}_APPLICATION_NAME is defined only in the case we are in the
# Main Project [Defined at the top level CMakeLists.txt]
if(DEFINED ${PROJECT_NAME}_APPLICATION_NAME)
if(${PROJECT_NAME} STREQUAL ${Slicer_MAIN_PROJECT})
if(Slicer_USE_CTKAPPLAUNCHER)
include(${CTKAPPLAUNCHER_DIR}/CMake/ctkAppLauncher.cmake)
......@@ -242,11 +250,11 @@ if(DEFINED ${PROJECT_NAME}_APPLICATION_NAME)
endforeach()
include(SlicerBlockCTKAppLauncherSettings)
set(splash_image_path ${Slicer_SOURCE_DIR}/Applications/${PROJECT_NAME}/Resources/Images/${Slicer_APPLICATION_NAME}SplashScreen.png)
set(splash_image_path ${Slicer_SOURCE_DIR}/Applications/${PROJECT_NAME}/Resources/Images/${SlicerApp_APPLICATION_NAME}SplashScreen.png)
ctkAppLauncherConfigure(
TARGET ${PROJECT_NAME}${SlicerApp_EXE_SUFFIX}
APPLICATION_INSTALL_SUBDIR ${Slicer_INSTALL_BIN_DIR}
APPLICATION_NAME ${Slicer_APPLICATION_NAME}
APPLICATION_NAME ${SlicerApp_APPLICATION_NAME}
SPLASH_IMAGE_PATH ${splash_image_path}
SPLASH_IMAGE_INSTALL_SUBDIR ${Slicer_INSTALL_BIN_DIR}
SPLASHSCREEN_HIDE_DELAY_MS 3000
......@@ -265,22 +273,22 @@ if(DEFINED ${PROJECT_NAME}_APPLICATION_NAME)
# HACK - Waiting "ctkAppLauncherConfigure" macro is updated so that it reconfigures the settings,
# if possible, only if "SlicerBlockCTKAppLauncherSettings.cmake" has been modified.
# Let's force a systematic reconfiguration of SlicerLauncherSettings.
add_custom_target(${Slicer_APPLICATION_NAME}RemoveLauncherSettings
add_custom_target(${SlicerApp_APPLICATION_NAME}RemoveLauncherSettings
COMMAND ${CMAKE_COMMAND} -E remove
${Slicer_BINARY_DIR}/${Slicer_APPLICATION_NAME}LauncherSettings.ini
${Slicer_BINARY_DIR}/${Slicer_APPLICATION_NAME}LauncherSettingsToInstall.ini
${Slicer_BINARY_DIR}/${SlicerApp_APPLICATION_NAME}LauncherSettings.ini
${Slicer_BINARY_DIR}/${SlicerApp_APPLICATION_NAME}LauncherSettingsToInstall.ini
)
add_dependencies(${Slicer_APPLICATION_NAME}RemoveLauncherSettings ${PROJECT_NAME}${SlicerApp_EXE_SUFFIX})
add_dependencies(${Slicer_APPLICATION_NAME}ConfigureLauncher ${Slicer_APPLICATION_NAME}RemoveLauncherSettings)
add_dependencies(${SlicerApp_APPLICATION_NAME}RemoveLauncherSettings ${PROJECT_NAME}${SlicerApp_EXE_SUFFIX})
add_dependencies(${SlicerApp_APPLICATION_NAME}ConfigureLauncher ${SlicerApp_APPLICATION_NAME}RemoveLauncherSettings)
if(NOT APPLE)
if(Slicer_HAS_CONSOLE_IO_SUPPORT)
install(PROGRAMS "${Slicer_BINARY_DIR}/${Slicer_APPLICATION_NAME}${CMAKE_EXECUTABLE_SUFFIX}" DESTINATION ".")
install(PROGRAMS "${Slicer_BINARY_DIR}/${SlicerApp_APPLICATION_NAME}${CMAKE_EXECUTABLE_SUFFIX}" DESTINATION ".")
else()
install(
PROGRAMS "${CTKAPPLAUNCHER_DIR}/bin/CTKAppLauncherW${CMAKE_EXECUTABLE_SUFFIX}"
DESTINATION "."
RENAME "${Slicer_APPLICATION_NAME}${CMAKE_EXECUTABLE_SUFFIX}"
RENAME "${SlicerApp_APPLICATION_NAME}${CMAKE_EXECUTABLE_SUFFIX}"
)
endif()
......@@ -289,9 +297,9 @@ if(DEFINED ${PROJECT_NAME}_APPLICATION_NAME)
DESTINATION ${Slicer_INSTALL_BIN_DIR}
)
install(
FILES "${Slicer_BINARY_DIR}/${Slicer_APPLICATION_NAME}LauncherSettingsToInstall.ini"
FILES "${Slicer_BINARY_DIR}/${SlicerApp_APPLICATION_NAME}LauncherSettingsToInstall.ini"
DESTINATION ${Slicer_INSTALL_BIN_DIR}
RENAME ${Slicer_APPLICATION_NAME}LauncherSettings.ini
RENAME ${SlicerApp_APPLICATION_NAME}LauncherSettings.ini
)
endif()
endif()
......
......@@ -1001,12 +1001,12 @@ QString qSlicerCoreApplication::launcherSettingsFilePath()const
#ifdef Q_OS_MAC
return QString();
#else
return this->slicerHome() + "/" Slicer_BIN_DIR "/" Slicer_APPLICATION_NAME "LauncherSettings.ini";
return this->slicerHome() + "/" Slicer_BIN_DIR "/" Slicer_MAIN_PROJECT_APPLICATION_NAME "LauncherSettings.ini";
#endif
}
else
{
return this->slicerHome() + "/" Slicer_APPLICATION_NAME "LauncherSettings.ini";
return this->slicerHome() + "/" Slicer_MAIN_PROJECT_APPLICATION_NAME "LauncherSettings.ini";
}
}
......
......@@ -49,7 +49,6 @@ Plugins = ${Slicer_QtPlugins_DIR}
RENAME qt.conf)
set(executable_path @executable_path)
set(Slicer_APPLICATION_NAME ${${Slicer_MAIN_PROJECT}_APPLICATION_NAME})
set(slicer_cpack_bundle_fixup_directory ${Slicer_BINARY_DIR}/CMake/SlicerCPackBundleFixup)
configure_file(
"${Slicer_SOURCE_DIR}/CMake/SlicerCPackBundleFixup.cmake.in"
......@@ -89,8 +88,8 @@ endif()
# Slicer does *NOT* require setting the windows path
set(CPACK_NSIS_MODIFY_PATH OFF)
set(APPLICATION_NAME "${${Slicer_MAIN_PROJECT}_APPLICATION_NAME}")
set(EXECUTABLE_NAME "${${Slicer_MAIN_PROJECT}_APPLICATION_NAME}")
set(APPLICATION_NAME "${Slicer_MAIN_PROJECT_APPLICATION_NAME}")
set(EXECUTABLE_NAME "${Slicer_MAIN_PROJECT_APPLICATION_NAME}")
set(CPACK_PACKAGE_EXECUTABLES "..\\\\${EXECUTABLE_NAME}" "${APPLICATION_NAME}")
# -------------------------------------------------------------------------
......
......@@ -265,5 +265,5 @@ function(fixup_bundle_with_plugins app)
)
endfunction()
fixup_bundle_with_plugins("@Slicer_APPLICATION_NAME@.app")
#verify_app("/Users/partyd/Kitware/Slicer4-trunk/build/Slicer-build/_CPack_Packages/Darwin/DragNDrop/Slicer-4.0.gamma-2011-05-10-Darwin/${${Slicer_MAIN_PROJECT}_APPLICATION_NAME}.app")
fixup_bundle_with_plugins("@Slicer_MAIN_PROJECT_APPLICATION_NAME@.app")
#verify_app("/Users/partyd/Kitware/Slicer4-trunk/build/Slicer-build/_CPack_Packages/Darwin/DragNDrop/Slicer-4.0.gamma-2011-05-10-Darwin/@Slicer_MAIN_PROJECT_APPLICATION_NAME@.app")
......@@ -19,11 +19,11 @@ endif()
# Sanity checks
set(expected_existing_vars Slicer_INSTALL_DIR)
set(expected_existing_vars Slicer_INSTALL_DIR Slicer_MAIN_PROJECT_APPLICATION_NAME)
foreach(var ${expected_existing_vars})
if(NOT EXISTS "${MY_${var}}")
message(FATAL_ERROR "Variable ${var} is set to an inexistent directory or file ! [${${var}}]")
endif()
endforeach()
verify_app("${Slicer_INSTALL_DIR}/${${Slicer_MAIN_PROJECT}_APPLICATION_NAME}.app")
verify_app("${Slicer_INSTALL_DIR}/${Slicer_MAIN_PROJECT_APPLICATION_NAME}.app")
......@@ -40,6 +40,10 @@ set(Slicer_WC_ROOT "@Slicer_WC_ROOT@")
set(Slicer_OS "@Slicer_OS@")
set(Slicer_ARCHITECTURE "@Slicer_ARCHITECTURE@")
# Slicer main application
set(Slicer_MAIN_PROJECT "@Slicer_MAIN_PROJECT@")
set(Slicer_MAIN_PROJECT_APPLICATION_NAME "@Slicer_MAIN_PROJECT_APPLICATION_NAME@")
# License and Readme file
set(Slicer_LICENSE_FILE "@Slicer_LICENSE_FILE_CONFIG@")
set(Slicer_README_FILE "@Slicer_README_FILE_CONFIG@")
......
......@@ -288,7 +288,7 @@ endfunction(fixup_extension)
# Fixup the .app bundles in the install tree:
#-----------------------------------------------------------------------------
function(fixup_slicer_extension)
set(app "@Slicer_APPLICATION_NAME@.app")
set(app "@Slicer_MAIN_PROJECT_APPLICATION_NAME@.app")
set(ext_dir "$ENV{DESTDIR}${CMAKE_INSTALL_PREFIX}/${app}")
set(suffix "@CMAKE_SHARED_LIBRARY_SUFFIX@")
set(exepath "${ext_dir}/Contents/MacOS")
......
......@@ -35,7 +35,7 @@
#define VTKSLICER_CONFIGURATION_TYPES "@CMAKE_CONFIGURATION_TYPES@"
#cmakedefine Slicer_BUILD_WIN32_CONSOLE
#define Slicer_APPLICATION_NAME "@${Slicer_MAIN_PROJECT}_APPLICATION_NAME@"
#define Slicer_MAIN_PROJECT_APPLICATION_NAME "@Slicer_MAIN_PROJECT_APPLICATION_NAME@"
#define Slicer_BIN_DIR "@Slicer_BIN_DIR@"
#define Slicer_LIB_DIR "@Slicer_LIB_DIR@"
#define Slicer_INCLUDE_DIR "@Slicer_INCLUDE_DIR@"
......
......@@ -298,6 +298,14 @@ mark_as_advanced(ADDITIONAL_CXX_FLAGS)
#-----------------------------------------------------------------------------
include(SlicerBlockCXXRequiredFlags)
#-----------------------------------------------------------------------------
# Main application
#-----------------------------------------------------------------------------
set(Slicer_MAIN_PROJECT SlicerApp)
set(${Slicer_MAIN_PROJECT}_APPLICATION_NAME Slicer)
set(Slicer_MAIN_PROJECT_APPLICATION_NAME ${${Slicer_MAIN_PROJECT}_APPLICATION_NAME})
#-----------------------------------------------------------------------------
# Slicer version number.
#-----------------------------------------------------------------------------
......@@ -350,11 +358,8 @@ endif()
#-----------------------------------------------------------------------------
# Slicer install directories
#-----------------------------------------------------------------------------
set(Slicer_MAIN_PROJECT SlicerApp)
set(${Slicer_MAIN_PROJECT}_APPLICATION_NAME Slicer)
set(Slicer_INSTALL_ROOT "./")
set(Slicer_BUNDLE_LOCATION "${${Slicer_MAIN_PROJECT}_APPLICATION_NAME}.app/Contents")
set(Slicer_BUNDLE_LOCATION "${Slicer_MAIN_PROJECT_APPLICATION_NAME}.app/Contents")
set(Slicer_BUNDLE_EXTENSIONS_DIRNAME "Extensions")
if(APPLE)
set(Slicer_INSTALL_ROOT "${Slicer_BUNDLE_LOCATION}/") # Set to create Bundle
......@@ -374,7 +379,7 @@ if(Slicer_BUILD_CLI_SUPPORT)
# is required for CLI executable to be located at same depth as Slicer executable.
# See also Slicer/CMake/SlicerCPackBundleFixup.cmake.in
#
# A more elegant solution would be to create a "Slicer.framework" on which both "${${Slicer_MAIN_PROJECT}_APPLICATION_NAME}.app"
# A more elegant solution would be to create a "Slicer.framework" on which both "${Slicer_MAIN_PROJECT_APPLICATION_NAME}.app"
# and the plugins/extensions (or loadable bundles) would depend on.
#
# NOTE: Make sure to update 'qSlicerCLIExecutableModuleFactory.cxx' if
......@@ -491,7 +496,7 @@ set(Slicer_ExternalData_URL_TEMPLATES ${ExternalData_URL_TEMPLATES})
#-----------------------------------------------------------------------------
# Testing
#-----------------------------------------------------------------------------
set(Slicer_LAUNCHER_EXECUTABLE ${Slicer_BINARY_DIR}/${${Slicer_MAIN_PROJECT}_APPLICATION_NAME})
set(Slicer_LAUNCHER_EXECUTABLE ${Slicer_BINARY_DIR}/${Slicer_MAIN_PROJECT_APPLICATION_NAME})
set(Slicer_LAUNCH_COMMAND ${Slicer_LAUNCHER_EXECUTABLE} --launcher-no-splash --launch)
if(BUILD_TESTING)
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment