Skip to content

Commit

Permalink
[CMake] Properly quote paths
Browse files Browse the repository at this point in the history
  • Loading branch information
ldionne committed May 3, 2017
1 parent b97e63e commit c9c2cda
Show file tree
Hide file tree
Showing 2 changed files with 5 additions and 5 deletions.
6 changes: 3 additions & 3 deletions CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -14,14 +14,14 @@ enable_testing()
include(compile_fail)
file(GLOB testfiles test/*.cpp)
foreach(testfile ${testfiles})
file(RELATIVE_PATH target ${CMAKE_CURRENT_SOURCE_DIR} ${testfile})
file(RELATIVE_PATH target "${CMAKE_CURRENT_SOURCE_DIR}" "${testfile}")
string(REPLACE .cpp "" target ${target})
string(REPLACE / "." target ${target})

if (${target} MATCHES "[.]fail")
compile_fail(${target} ${testfile})
compile_fail(${target} "${testfile}")
else()
add_executable(${target} ${testfile})
add_executable(${target} "${testfile}")
add_test(${target} ${target})
endif()

Expand Down
4 changes: 2 additions & 2 deletions cmake/compile_fail.cmake
Original file line number Diff line number Diff line change
Expand Up @@ -7,10 +7,10 @@
# file fails to compile.

function(compile_fail testname sourcefile)
add_executable(${testname} ${sourcefile})
add_executable(${testname} "${sourcefile}")
set_target_properties(${testname} PROPERTIES EXCLUDE_FROM_ALL true
EXCLUDE_FROM_DEFAULT_BUILD true)
add_test(NAME ${testname}
COMMAND ${CMAKE_COMMAND} --build ${CMAKE_BINARY_DIR} --target ${testname} --config $<CONFIGURATION>)
COMMAND ${CMAKE_COMMAND} --build "${CMAKE_BINARY_DIR}" --target ${testname} --config $<CONFIGURATION>)
set_tests_properties(${testname} PROPERTIES WILL_FAIL true)
endfunction()

0 comments on commit c9c2cda

Please sign in to comment.