-
Notifications
You must be signed in to change notification settings - Fork 50
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
* add-cmake-3-support: ENH: Re-factor GenerateCLP tests to support multi config system ENH: Add support for CMake 3.0 removing use of LOCATION target property ENH: Set default value for CMAKE_BUILD_TYPE
- Loading branch information
Showing
20 changed files
with
401 additions
and
104 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
File renamed without changes.
File renamed without changes.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,82 @@ | ||
cmake_minimum_required(VERSION 2.8.2) | ||
project(CLPExample1) | ||
|
||
find_package(GenerateCLP NO_MODULE REQUIRED) | ||
include(${GenerateCLP_USE_FILE}) | ||
|
||
#----------------------------------------------------------------------------- | ||
if(GenerateCLP_USE_JSONCPP) | ||
set(CMAKE_MODULE_PATH ${JsonCpp_CMAKE_MODULE_PATH} ${CMAKE_MODULE_PATH}) # Needed to locate FindJsonCpp.cmake | ||
find_package(JsonCpp REQUIRED) | ||
include_directories(${JsonCpp_INCLUDE_DIRS}) | ||
endif() | ||
|
||
set(_additional_link_libraries) | ||
if(GenerateCLP_USE_JSONCPP) | ||
list(APPEND _additional_link_libraries ${JsonCpp_LIBRARIES}) | ||
endif() | ||
if(GenerateCLP_USE_SERIALIZER) | ||
list(APPEND _additional_link_libraries ${ParameterSerializer_LIBRARIES}) | ||
endif() | ||
|
||
#----------------------------------------------------------------------------- | ||
# Build | ||
#----------------------------------------------------------------------------- | ||
|
||
set(${PROJECT_NAME}_SOURCE ${PROJECT_NAME}.cxx) | ||
GENERATECLP(${PROJECT_NAME}_SOURCE ${PROJECT_NAME}.xml) | ||
add_executable(${PROJECT_NAME} ${${PROJECT_NAME}_SOURCE}) | ||
target_link_libraries(${PROJECT_NAME} ITKEXPAT ${_additional_link_libraries}) | ||
|
||
#----------------------------------------------------------------------------- | ||
# Test | ||
#----------------------------------------------------------------------------- | ||
include(CTest) | ||
|
||
set(TEMP ${PROJECT_BINARY_DIR}/Testing/Temporary) | ||
file(MAKE_DIRECTORY ${TEMP}) | ||
|
||
if(GenerateCLP_USE_SERIALIZER) | ||
add_test(NAME GenerateCLPSerializer-${PROJECT_NAME}-Test1 | ||
COMMAND $<TARGET_FILE:${PROJECT_NAME}> | ||
--spatialsamples 3324 | ||
--selection 4 | ||
--interpolation sinc | ||
--learningrate 0.002,0.001,0.0007,0.0002 | ||
--translationscale 20 | ||
--serialize ./GenerateCLPSerializer-${PROJECT_NAME}-Test1.json | ||
2 | ||
Head.mha | ||
ProgrammingHead.mha | ||
ShrunkHead.mha | ||
WORKING_DIRECTORY ${TEMP} | ||
) | ||
|
||
add_test(NAME GenerateCLPSerializer-${PROJECT_NAME}-Test2 | ||
COMMAND $<TARGET_FILE:${PROJECT_NAME}> | ||
--deserialize ./GenerateCLPSerializer-${PROJECT_NAME}-Test1.json | ||
--serialize ./GenerateCLPSerializer-${PROJECT_NAME}-Test2.json | ||
2 | ||
Head.mha | ||
ProgrammingHead.mha | ||
ShrunkHead.mha | ||
WORKING_DIRECTORY ${TEMP} | ||
) | ||
set_tests_properties( GenerateCLPSerializer-${PROJECT_NAME}-Test2 | ||
PROPERTIES DEPENDS GenerateCLPSerializer-${PROJECT_NAME}-Test1) | ||
|
||
add_test(NAME GenerateCLPSerializer-${PROJECT_NAME}-Test3 | ||
COMMAND $<TARGET_FILE:${PROJECT_NAME}> | ||
--deserialize ./GenerateCLPSerializer-${PROJECT_NAME}-Test1.json | ||
--serialize ./GenerateCLPSerializer-${PROJECT_NAME}-Test3.json | ||
--spatialsamples 2112 | ||
--learningrate 0.001,0.001,0.0005,0.0003 | ||
2 | ||
Head.mha | ||
ProgrammingHead.mha | ||
ShrunkHead.mha | ||
WORKING_DIRECTORY ${TEMP} | ||
) | ||
set_tests_properties( GenerateCLPSerializer-${PROJECT_NAME}-Test3 | ||
PROPERTIES DEPENDS GenerateCLPSerializer-${PROJECT_NAME}-Test1) | ||
endif() |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,24 @@ | ||
|
||
|
||
include(${TEST_SOURCE_DIR}/../CMake/GenerateCLPTestMacros.cmake) | ||
include(${TEST_BINARY_DIR}/../CMake/GenerateCLPTestPrerequisites.cmake) | ||
|
||
# -------------------------------------------------------------------------- | ||
# Debug flags - Set to True to display the command as string | ||
set(PRINT_COMMAND 0) | ||
|
||
# -------------------------------------------------------------------------- | ||
# Build | ||
set(command ${CMAKE_COMMAND} --build ${TEST_BINARY_DIR} --config ${generateclp_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() |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,49 @@ | ||
|
||
include(${TEST_SOURCE_DIR}/../CMake/GenerateCLPTestMacros.cmake) | ||
include(${TEST_BINARY_DIR}/../CMake/GenerateCLPTestPrerequisites.cmake) | ||
|
||
if(${generateclp_build_type} STREQUAL "") | ||
message(FATAL_ERROR "Make sure variable TEST_BUILD_TYPE is not empty. " | ||
"TEST_BUILD_TYPE [${test_build_type}]") | ||
endif() | ||
|
||
# -------------------------------------------------------------------------- | ||
# Delete build directory if it exists | ||
execute_process( | ||
COMMAND ${CMAKE_COMMAND} -E remove_directory ${TEST_BINARY_DIR} | ||
) | ||
|
||
# -------------------------------------------------------------------------- | ||
# Create build directory | ||
execute_process( | ||
COMMAND ${CMAKE_COMMAND} -E make_directory ${TEST_BINARY_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=${generateclp_build_type} | ||
-DGenerateCLP_DIR:PATH=${GenerateCLP_BINARY_DIR} | ||
-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} | ||
OUTPUT_VARIABLE ov | ||
RESULT_VARIABLE rv | ||
) | ||
|
||
print_command_as_string("${command}") | ||
|
||
if(rv) | ||
message(FATAL_ERROR "Failed to configure Test:\n${ov}") | ||
endif() |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,26 @@ | ||
|
||
|
||
include(${TEST_SOURCE_DIR}/../CMake/GenerateCLPTestMacros.cmake) | ||
include(${TEST_BINARY_DIR}/../CMake/GenerateCLPTestPrerequisites.cmake) | ||
|
||
# -------------------------------------------------------------------------- | ||
# Debug flags - Set to True to display the command as string | ||
set(PRINT_COMMAND 0) | ||
|
||
# -------------------------------------------------------------------------- | ||
# Build | ||
set(command ${CMAKE_CTEST_COMMAND} -C ${generateclp_build_type}) | ||
execute_process( | ||
COMMAND ${command} | ||
WORKING_DIRECTORY ${TEST_BINARY_DIR} | ||
OUTPUT_VARIABLE ov | ||
RESULT_VARIABLE rv | ||
) | ||
|
||
print_command_as_string("${command}") | ||
|
||
message(${ov}) | ||
|
||
if(rv) | ||
message(FATAL_ERROR "Failed to run Test:\n${ov}") | ||
endif() |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,13 @@ | ||
|
||
# -------------------------------------------------------------------------- | ||
# Helper macro | ||
function(print_command_as_string command) | ||
if(PRINT_COMMAND) | ||
set(command_as_string) | ||
foreach(elem ${command}) | ||
set(command_as_string "${command_as_string} ${elem}") | ||
endforeach() | ||
message(STATUS "COMMAND:${command_as_string}") | ||
endif() | ||
endfunction() | ||
|
46 changes: 46 additions & 0 deletions
46
GenerateCLP/Testing/CMake/GenerateCLPTestPrerequisites.cmake.in
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,46 @@ | ||
|
||
|
||
set(CMAKE_CONFIGURATION_TYPES "@CMAKE_CONFIGURATION_TYPES@") | ||
set(CMAKE_BUILD_TYPE "@CMAKE_BUILD_TYPE@") | ||
set(CMAKE_EXECUTABLE_SUFFIX "@CMAKE_EXECUTABLE_SUFFIX@") | ||
|
||
set(generateclp_cmake_generator "@CMAKE_GENERATOR@") | ||
set(GenerateCLP_BINARY_DIR "@GenerateCLP_BINARY_DIR@") | ||
|
||
set(GenerateCLP_USE_JSONCPP @GenerateCLP_USE_JSONCPP@) | ||
set(JsonCpp_DIR "@JsonCpp_DIR@") | ||
|
||
set(JsonCpp_CMAKE_MODULE_PATH "@SlicerExecutionModel_SOURCE_DIR@/CMake") | ||
|
||
# -------------------------------------------------------------------------- | ||
# Sanity checks | ||
|
||
if(NOT EXISTS ${GenerateCLP_BINARY_DIR}) | ||
message(FATAL_ERROR "Make sure variable GenerateCLP_BINARY_DIR is set to a valid directory. " | ||
"GenerateCLP_BINARY_DIR [${GenerateCLP_BINARY_DIR}]") | ||
endif() | ||
|
||
|
||
# -------------------------------------------------------------------------- | ||
# Attempt to guess GenerateCLP build type | ||
|
||
set(generateclp_dir ${GenerateCLP_BINARY_DIR}/bin) | ||
if(CMAKE_CONFIGURATION_TYPES) | ||
foreach (type ${CMAKE_CONFIGURATION_TYPES}) | ||
if(EXISTS ${generateclp_dir}/${type}/GenerateCLPLauncher${CMAKE_EXECUTABLE_SUFFIX}) | ||
set(generateclp_build_type ${type}) | ||
break() | ||
endif() | ||
if(EXISTS ${generateclp_dir}/${type}/GenerateCLP${CMAKE_EXECUTABLE_SUFFIX}) | ||
set(generateclp_build_type ${type}) | ||
break() | ||
endif() | ||
endforeach() | ||
else() | ||
set(generateclp_build_type "${CMAKE_BUILD_TYPE}") | ||
endif() | ||
|
||
if("${generateclp_build_type}" STREQUAL "") | ||
message(FATAL_ERROR "'generateclp_build_type' shouldn't be empty !") | ||
endif() | ||
|
Oops, something went wrong.