Skip to content

Support installation (rebased) #61

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Open
wants to merge 5 commits into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
8 changes: 8 additions & 0 deletions CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -133,6 +133,11 @@ if(NOT DEFINED SlicerExecutionModel_DEFAULT_CLI_INSTALL_ARCHIVE_DESTINATION)
set(SlicerExecutionModel_DEFAULT_CLI_INSTALL_ARCHIVE_DESTINATION lib)
endif()


if(NOT DEFINED SlicerExecutionModel_SHARE_DESTINATION)
set(SlicerExecutionModel_SHARE_DESTINATION share)
endif()

#-----------------------------------------------------------------------------
# Define default "cli library wrapper" used by SEMMacroBuildCLI.cmake
#-----------------------------------------------------------------------------
Expand Down Expand Up @@ -224,4 +229,7 @@ foreach(SCRIPT ${allscripts})
get_filename_component(_fileName ${SCRIPT} NAME)
configure_file(${SCRIPT}
${CMAKE_CURRENT_BINARY_DIR}/CMake/${_fileName} COPYONLY IMMEDIATE)
install(FILES ${SCRIPT} DESTINATION ${SlicerExecutionModel_SHARE_DESTINATION}
COMPONENT Development
)
endforeach()
63 changes: 42 additions & 21 deletions GenerateCLP/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -67,6 +67,14 @@ endif()
#-----------------------------------------------------------------------------
include(CTest)

#-----------------------------------------------------------------------------
# Install tree directories
#-----------------------------------------------------------------------------

if(NOT DEFINED GenerateCLP_INSTALL_CMAKE_DIR)
set(GenerateCLP_INSTALL_CMAKE_DIR lib/GenerateCLP)
endif()

#-----------------------------------------------------------------------------
# Output directories.
#-----------------------------------------------------------------------------
Expand Down Expand Up @@ -127,27 +135,12 @@ if(NOT DEFINED GenerateCLP_INSTALL_BIN_DIR)
set(GenerateCLP_INSTALL_BIN_DIR bin)
endif()
if(NOT DEFINED ${PROJECT_NAME}_INSTALL_NO_DEVELOPMENT)
set(${PROJECT_NAME}_INSTALL_NO_DEVELOPMENT ON)
set(${PROJECT_NAME}_INSTALL_NO_DEVELOPMENT OFF)
endif()
if(NOT ${PROJECT_NAME}_INSTALL_NO_DEVELOPMENT)
install(TARGETS GenerateCLP RUNTIME
DESTINATION ${GenerateCLP_INSTALL_BIN_DIR} COMPONENT Development
)
endif()

# --------------------------------------------------------------------------
# Install support files
# --------------------------------------------------------------------------
if(NOT ${PROJECT_NAME}_INSTALL_NO_DEVELOPMENT)
install(FILES ${GenerateCLP_BINARY_DIR}/GenerateCLPConfig.cmake_install
DESTINATION lib/GenerateCLP
COMPONENT Development
RENAME GenerateCLPConfig.cmake
)
install(FILES ${GenerateCLP_BINARY_DIR}/UseGenerateCLP.cmake_install
DESTINATION lib/GenerateCLP
install(TARGETS GenerateCLP
RUNTIME DESTINATION ${GenerateCLP_INSTALL_BIN_DIR}
COMPONENT Development
RENAME UseGenerateCLP.cmake
)
endif()

Expand Down Expand Up @@ -177,12 +170,12 @@ set(GenerateCLP_FORWARD_PATH_BUILD " \\
")
set(GenerateCLP_FORWARD_PATH_INSTALL " \\
\".\", \\
\"${ITK_DIR}/bin\", \\
\"${ITK_DIR}/lib\", \\
${json_forward_path_install} \\
\"${ModuleDescriptionParser_DIR}/bin\" \\
")
set(GenerateCLP_FORWARD_EXE GenerateCLP)
set(GenerateCLP_FORWARD_DIR_INSTALL "..")
set(GenerateCLP_FORWARD_DIR_INSTALL ".")

# --------------------------------------------------------------------------
# Build launcher
Expand Down Expand Up @@ -231,10 +224,38 @@ set(${PROJECT_NAME}_INCLUDE_DIRS ${CMAKE_CURRENT_SOURCE_DIR} ${CMAKE_CURRENT_BIN
configure_file(
GenerateCLP.cmake
${CMAKE_CURRENT_BINARY_DIR}/GenerateCLP.cmake
@ONLY
COPYONLY
)
include(GenerateGenerateCLPConfig.cmake)

# --------------------------------------------------------------------------
# Install support files
# --------------------------------------------------------------------------
if(NOT ${PROJECT_NAME}_INSTALL_NO_DEVELOPMENT)

install(FILES ${CMAKE_CURRENT_BINARY_DIR}/GenerateCLP.cmake
DESTINATION ${GenerateCLP_INSTALL_CMAKE_DIR}
COMPONENT Development
)

configure_file(
GenerateCLPInstallConfig.cmake.in
${GenerateCLP_BINARY_DIR}/GenerateCLPConfig.cmake_install
@ONLY
)
install(FILES ${GenerateCLP_BINARY_DIR}/GenerateCLPConfig.cmake_install
DESTINATION lib/GenerateCLP
COMPONENT Development
RENAME GenerateCLPConfig.cmake
)

install(FILES ${GenerateCLP_SOURCE_DIR}/UseGenerateCLP.cmake.in
DESTINATION lib/GenerateCLP
COMPONENT Development
RENAME UseGenerateCLP.cmake
)
endif()

# --------------------------------------------------------------------------
# Testing
# --------------------------------------------------------------------------
Expand Down
1 change: 1 addition & 0 deletions GenerateCLP/GenerateCLPInstallConfig.cmake.in
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,7 @@ endif(WIN32)

set(GenerateCLP_INCLUDE_DIRS "${GenerateCLP_CONFIG_DIR}/../../include/GenerateCLP")
set(GenerateCLP_LIBRARY_DIRS "${GenerateCLP_CONFIG_DIR}")
set(GenerateCLP_CMAKE_DIR "${GenerateCLP_CONFIG_DIR}")
set(GenerateCLP_USE_FILE "${GenerateCLP_CONFIG_DIR}/UseGenerateCLP.cmake")
set(GENERATECLP_EXE "${GenerateCLP_CONFIG_DIR}/../../bin/GenerateCLP")
if(NOT WIN32)
Expand Down
96 changes: 96 additions & 0 deletions GenerateCLP/Testing/CMake/GenerateCLP-Install.cmake
Original file line number Diff line number Diff line change
@@ -0,0 +1,96 @@

# --------------------------------------------------------------------------
# Sanity checks

foreach(varname
CMAKE_BUILD_TYPE
CMAKE_GENERATOR
ModuleDescriptionParser_DIR
TCLAP_DIR
TEST_CMAKE_DIR
TEST_SOURCE_DIR
TEST_BINARY_DIR
TEST_INSTALL_DIR
)
if(NOT DEFINED ${varname})
message(FATAL_ERROR "Variable ${varname} is not DEFINED")
endif()
endforeach()

include(${TEST_CMAKE_DIR}/GenerateCLPTestMacros.cmake)

# --------------------------------------------------------------------------
# Delete build and install directory if they exists
execute_process(
COMMAND ${CMAKE_COMMAND} -E remove_directory ${TEST_BINARY_DIR}
COMMAND ${CMAKE_COMMAND} -E remove_directory ${TEST_INSTALL_DIR}
)

# --------------------------------------------------------------------------
# Create build and install directories
execute_process(
COMMAND ${CMAKE_COMMAND} -E make_directory ${TEST_BINARY_DIR}
COMMAND ${CMAKE_COMMAND} -E make_directory ${TEST_INSTALL_DIR}
)

# --------------------------------------------------------------------------
# Debug flags - Set to True to display the command as string
set(PRINT_COMMAND 0)

# --------------------------------------------------------------------------
# Configure
set(command ${CMAKE_COMMAND}
-DCMAKE_BUILD_TYPE:STRING=${CMAKE_BUILD_TYPE}
-DCMAKE_INSTALL_PREFIX:PATH=${TEST_INSTALL_DIR}
-DModuleDescriptionParser_DIR:PATH=${ModuleDescriptionParser_DIR}
-DTCLAP_DIR:PATH=${TCLAP_DIR}
-G ${CMAKE_GENERATOR} ${TEST_SOURCE_DIR})
execute_process(
COMMAND ${command}
WORKING_DIRECTORY ${TEST_BINARY_DIR}
OUTPUT_VARIABLE ov
RESULT_VARIABLE rv
)

print_command_as_string("${command}")

if(rv)
message(FATAL_ERROR "Failed to configure Test:\n${ov}")
endif()

# --------------------------------------------------------------------------
# Build

set(command ${CMAKE_COMMAND} --build ${TEST_BINARY_DIR} --config ${CMAKE_BUILD_TYPE})
execute_process(
COMMAND ${command}
WORKING_DIRECTORY ${TEST_BINARY_DIR}
OUTPUT_VARIABLE ov
RESULT_VARIABLE rv
)

print_command_as_string("${command}")

if(rv)
message(FATAL_ERROR "Failed to build Test:\n${ov}")
endif()

# --------------------------------------------------------------------------
# Install
set(install_target install)
if(WIN32)
set(install_target INSTALL)
endif()
set(command ${CMAKE_COMMAND} --build ${TEST_BINARY_DIR} --config ${CMAKE_BUILD_TYPE} --target ${install_target})
execute_process(
COMMAND ${command}
WORKING_DIRECTORY ${TEST_BINARY_DIR}
OUTPUT_VARIABLE ov
RESULT_VARIABLE rv
)

print_command_as_string("${command}")

if(rv)
message(FATAL_ERROR "Failed to install Test:\n${ov}")
endif()
12 changes: 11 additions & 1 deletion GenerateCLP/Testing/CMake/GenerateCLPTest-Configure.cmake
Original file line number Diff line number Diff line change
Expand Up @@ -23,14 +23,24 @@ execute_process(
# Debug flags - Set to True to display the command as string
set(PRINT_COMMAND 0)

# --------------------------------------------------------------------------
if(TEST_TREETYPE STREQUAL "BuildTree")
set(GenerateCLP_DIR ${GenerateCLP_BINARY_DIR})
endif()

# --------------------------------------------------------------------------
# Configure
set(command ${CMAKE_COMMAND}
-DCMAKE_BUILD_TYPE:STRING=${generateclp_build_type}
-DGenerateCLP_DIR:PATH=${GenerateCLP_BINARY_DIR}
-DGenerateCLP_DIR:PATH=${GenerateCLP_DIR}
-DGenerateCLP_USE_JSONCPP:BOOL=${GenerateCLP_USE_JSONCPP}
-DJsonCpp_CMAKE_MODULE_PATH:PATH=${JsonCpp_CMAKE_MODULE_PATH}
-G ${generateclp_cmake_generator} ${TEST_SOURCE_DIR})
if(GenerateCLP_USE_JSONCPP)
list(APPEND command
-DJsonCpp_DIR:PATH=${JsonCpp_DIR}
)
endif()
execute_process(
COMMAND ${command}
WORKING_DIRECTORY ${TEST_BINARY_DIR}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -21,6 +21,11 @@ if(NOT EXISTS ${GenerateCLP_BINARY_DIR})
"GenerateCLP_BINARY_DIR [${GenerateCLP_BINARY_DIR}]")
endif()

if(NOT ("${TEST_TREETYPE}" STREQUAL "BuildTree" OR "${TEST_TREETYPE}" STREQUAL "InstallTree"))
message(FATAL_ERROR "Variable TEST_TREETYPE is expected to be set to either 'BuildTree' or 'InstallTree'.
Current value is '${TEST_TREETYPE}'")
endif()


# --------------------------------------------------------------------------
# Attempt to guess GenerateCLP build type
Expand Down
68 changes: 57 additions & 11 deletions GenerateCLP/Testing/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -8,23 +8,69 @@ configure_file(
@ONLY
)

#
# Add test installing GenerateCLP
#

set(GenerateCLPTest_INSTALL_PREFIX ${CMAKE_CURRENT_BINARY_DIR}/GenerateCLP-install)

if(CMAKE_CONFIGURATION_TYPES)
set(_build_type ${CMAKE_CFG_INTDIR})
else()
set(_build_type ${CMAKE_BUILD_TYPE})
endif()
add_test(NAME GenerateCLP-Install
COMMAND ${CMAKE_COMMAND}
-DBUILD_TESTING:BOOL=OFF
-DCMAKE_BUILD_TYPE:STRING=${_build_type}
-DCMAKE_GENERATOR:STRING=${CMAKE_GENERATOR}
-DModuleDescriptionParser_DIR:PATH=${ModuleDescriptionParser_BINARY_DIR}
-DTCLAP_DIR:PATH=${TCLAP_BINARY_DIR}
-DTEST_CMAKE_DIR:PATH=${GenerateCLP_SOURCE_DIR}/Testing/CMake
-DTEST_BINARY_DIR:PATH=${CMAKE_CURRENT_BINARY_DIR}/GenerateCLP-build
-DTEST_INSTALL_DIR:PATH=${GenerateCLPTest_INSTALL_PREFIX}
-DTEST_SOURCE_DIR:PATH=${GenerateCLP_SOURCE_DIR}
-P ${CMAKE_CURRENT_SOURCE_DIR}/CMake/GenerateCLP-Install.cmake)
set_property(TEST GenerateCLP-Install PROPERTY LABELS ${PROJECT_NAME})

#
# Helper macro
#
set(_previous_test "NODEPENDS")
macro(generateclp_add_test cliname stepname)
set(testname GenerateCLPTest-${cliname}-${stepname})
add_test(NAME ${testname}
COMMAND ${CMAKE_COMMAND}
-DTEST_SOURCE_DIR:PATH=${CMAKE_CURRENT_SOURCE_DIR}/${cliname}
-DTEST_BINARY_DIR:PATH=${CMAKE_CURRENT_BINARY_DIR}/${cliname}
-DTEST_CONFIGURATION:STRING=$<CONFIGURATION>
-P ${CMAKE_CURRENT_SOURCE_DIR}/CMake/GenerateCLPTest-${stepname}.cmake)
if(NOT ${_previous_test} STREQUAL "NODEPENDS")
set_tests_properties(${testname} PROPERTIES DEPENDS ${_previous_test})

macro(_generateclp_add_tree_test treetype)
set(testname GenerateCLPTest-${treetype}-${cliname}-${stepname})
set(_test_args
-DTEST_TREETYPE:STRING=${treetype}
-DTEST_SOURCE_DIR:PATH=${CMAKE_CURRENT_SOURCE_DIR}/${cliname}
-DTEST_BINARY_DIR:PATH=${CMAKE_CURRENT_BINARY_DIR}/${treetype}-${cliname}
-DTEST_CONFIGURATION:STRING=$<CONFIGURATION>
)
if("${treetype}" STREQUAL "InstallTree" AND "${stepname}" STREQUAL "Configure")
list(APPEND _test_args
-DGenerateCLP_DIR:PATH=${GenerateCLPTest_INSTALL_PREFIX}/lib/GenerateCLP/
)
endif()

add_test(NAME ${testname}
COMMAND ${CMAKE_COMMAND} ${_test_args}
-P ${CMAKE_CURRENT_SOURCE_DIR}/CMake/GenerateCLPTest-${stepname}.cmake)
if(NOT ${_previous_test} STREQUAL "NODEPENDS")
set_tests_properties(${testname} PROPERTIES DEPENDS ${_previous_test})
endif()
set(_previous_test ${testname})
set_property(TEST ${testname} PROPERTY LABELS ${PROJECT_NAME})
endmacro()

# Build and install cases
_generateclp_add_tree_test(BuildTree)
_generateclp_add_tree_test(InstallTree)
if(stepname STREQUAL "Configure")
# Install case required GenerareCLP install tree
set_tests_properties(${testname} PROPERTIES DEPENDS GenerateCLP-Install)
endif()
set(_previous_test ${testname})
set_property(TEST ${testname} PROPERTY LABELS ${PROJECT_NAME})

endmacro()

#
Expand Down