Last active
December 14, 2015 19:39
-
-
Save jcfr/5137833 to your computer and use it in GitHub Desktop.
Toy project illustrating an issue when using semicolon with ExternalData_add_test parameters.
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 CMakeLists.txt will download or configure all files required | |
# to illustrate the issue occuring when "ExternalData_add_test" is | |
# used with parameters having ";". | |
# | |
# | |
# This testcase has been developer on Ubuntu 10.04 using cmake 2.8.10.2 | |
# | |
# Usage: | |
# | |
# mkdir ExternalDataTestWithSemicolon | |
# cd ExternalDataTestWithSemicolon | |
# # Add this CMakeLists.txt to the newly created folder | |
# mkdir build | |
# cmake ../ | |
# ctest -V | |
# | |
# Test "ExternalDataTestWithSemicolon" is expected to pass. | |
# | |
# | |
cmake_minimum_required(VERSION 2.8.10) | |
project(ExternalDataParamWithSemicolon) | |
#----------------------------------------------------------------------------- | |
# Download ExternalData module | |
message(STATUS "Downloading ExternalData.cmake") | |
file(DOWNLOAD | |
"http://cmake.org/gitweb?p=cmake.git;a=blob_plain;f=Modules/ExternalData.cmake;h=9d84f8d135ae8b4e86d78a2e3b570a3b520445a1;hb=HEAD" | |
${CMAKE_CURRENT_BINARY_DIR}/ExternalData.cmake | |
) | |
file(DOWNLOAD | |
"http://cmake.org/gitweb?p=cmake.git;a=blob_plain;f=Modules/ExternalData_config.cmake.in;h=0858f53688e607a18c377a555e07a65c9e991ea4;hb=HEAD" | |
${CMAKE_CURRENT_BINARY_DIR}/ExternalData_config.cmake.in | |
) | |
message(STATUS "Downloading ExternalData.cmake - ok") | |
#----------------------------------------------------------------------------- | |
# Download test data md5 file | |
message(STATUS "Downloading MR-head.nrrd.md5") | |
file(MAKE_DIRECTORY "${CMAKE_CURRENT_SOURCE_DIR}/Data/Input") | |
file(DOWNLOAD | |
"http://slicer.kitware.com/midas3/keyfiles/download/bitstream?bitstreamId=35886" | |
"${CMAKE_CURRENT_SOURCE_DIR}/Data/Input/MR-head.nrrd.md5" | |
) | |
message(STATUS "Downloading MR-head.nrrd.md5 - ok") | |
#----------------------------------------------------------------------------- | |
# src/main.cpp | |
file(WRITE "${CMAKE_CURRENT_SOURCE_DIR}/src/main.cpp" | |
"#include <iostream> | |
#include <cstdlib> | |
#include <cstring> | |
int main(int argc, char* argv[]) | |
{ | |
if (argc < 3) | |
{ | |
std::cerr << \"Missing arguments !\" << std::endl; | |
return EXIT_FAILURE; | |
} | |
if (strcmp(\"import foo; foo.bar()\", argv[2]) != 0) | |
{ | |
std::cerr << \"Current argument [\" << argv[2] << \"] - expected: [import foo; foo.bar()]\" << std::endl; | |
return EXIT_FAILURE; | |
} | |
std::cout << \"Hello World \" << std::endl; | |
return EXIT_SUCCESS; | |
}") | |
add_executable(HelloWorld src/main.cpp) | |
#----------------------------------------------------------------------------- | |
message(STATUS "Configuring ExternalData") | |
include(CTest) | |
list(APPEND ExternalData_URL_TEMPLATES "http://slicer.kitware.com/midas3/api/rest?method=midas.bitstream.download&checksum=%(hash)") | |
set(ExternalData_OBJECT_STORES ${CMAKE_BINARY_DIR}/ExternalData/Objects) | |
include(${CMAKE_CURRENT_BINARY_DIR}/ExternalData.cmake) | |
message(STATUS "Configuring ExternalData - ok") | |
#----------------------------------------------------------------------------- | |
message(STATUS "Writing Level1/Level2/CMakeLists.txt") | |
file(MAKE_DIRECTORY "${CMAKE_CURRENT_SOURCE_DIR}/Level1/Level2") | |
file(WRITE "${CMAKE_CURRENT_SOURCE_DIR}/Level1/Level2/CMakeLists.txt" | |
" | |
add_test( | |
NAME RegularTestWithSemicolon | |
COMMAND $<TARGET_FILE:HelloWorld> --code \"import foo; foo.bar()\" | |
) | |
add_test( | |
NAME RegularTestCheckHelloWorldFailureCase | |
COMMAND $<TARGET_FILE:HelloWorld> --code \"import foo foo.bar()\" | |
) | |
set_property(TEST RegularTestCheckHelloWorldFailureCase PROPERTY WILL_FAIL TRUE) | |
ExternalData_add_test(MyData | |
NAME ExternalDataTestWithSemicolon | |
COMMAND $<TARGET_FILE:HelloWorld> --code \"import foo; foo.bar()\" DATA{../../Data/Input/MR-head.nrrd} | |
) | |
ExternalData_add_test(MyData | |
NAME ExternalDataTestWithSemicolonUsingGeneratorExpression | |
COMMAND $<TARGET_FILE:HelloWorld> --code \"import foo$<SEMICOLON> foo.bar()\" DATA{../../Data/Input/MR-head.nrrd} | |
) | |
") | |
message(STATUS "Writing Level1/Level2/CMakeLists.txt - ok") | |
add_subdirectory(Level1/Level2) | |
#----------------------------------------------------------------------------- | |
ExternalData_Add_Target(MyData) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment