diff --git a/.gitignore b/.gitignore index b892947c..c57a8996 100644 --- a/.gitignore +++ b/.gitignore @@ -12,4 +12,3 @@ docs/doxyxml/ #*# *~ .DS_Store -tests/runner-autogen.cpp diff --git a/cmake/generate-tests b/cmake/generate-tests index deaacd6c..7edae32f 100755 --- a/cmake/generate-tests +++ b/cmake/generate-tests @@ -1,2 +1,2 @@ cd ${0%/*} -../third-party/cxxtest/bin/cxxtestgen --runner=ErrorPrinter -o ../tests/runner-autogen.cpp ../tests/*.hpp ../source/*/tests/*.hpp \ No newline at end of file +../third-party/cxxtest/bin/cxxtestgen --runner=ErrorPrinter -o "$1"/tests/runner-autogen.cpp ../tests/*.hpp ../source/*/tests/*.hpp diff --git a/cmake/generate-tests.bat b/cmake/generate-tests.bat index 269338a2..70960f71 100644 --- a/cmake/generate-tests.bat +++ b/cmake/generate-tests.bat @@ -1,2 +1,2 @@ cd %~dp0 -../third-party/cxxtest/bin/cxxtestgen --runner=ErrorPrinter -o ../tests/runner-autogen.cpp ../tests/*.hpp ../source/*/tests/*.hpp \ No newline at end of file +../third-party/cxxtest/bin/cxxtestgen --runner=ErrorPrinter -o "%1"/tests/runner-autogen.cpp ../tests/*.hpp ../source/*/tests/*.hpp diff --git a/cmake/xlnt.test.cmake b/cmake/xlnt.test.cmake index 7d92fef8..b4cced01 100644 --- a/cmake/xlnt.test.cmake +++ b/cmake/xlnt.test.cmake @@ -25,8 +25,8 @@ FILE(GLOB TEST_HELPERS_SOURCES tests/helpers/*.cpp) SET(TEST_HELPERS ${TEST_HELPERS_HEADERS} ${TEST_HELPERS_SOURCES}) -file(WRITE tests/runner-autogen.cpp "#error This file should be generated from tests before compiling") -SET(RUNNER tests/runner-autogen.cpp) +SET(RUNNER "${CMAKE_CURRENT_BINARY_DIR}/tests/runner-autogen.cpp") +SET_SOURCE_FILES_PROPERTIES(${RUNNER} PROPERTIES GENERATED TRUE) add_executable(xlnt.test ${TEST_HELPERS} ${TESTS} ${RUNNER} ) @@ -59,9 +59,13 @@ if(${CMAKE_CXX_COMPILER_ID} STREQUAL "MSVC") target_link_libraries(xlnt.test Shlwapi) endif() -add_custom_target (generate-test-runner - COMMAND ${CMAKE_CURRENT_SOURCE_DIR}/cmake/generate-tests +add_custom_command(OUTPUT ${RUNNER} + COMMAND ${CMAKE_CURRENT_SOURCE_DIR}/cmake/generate-tests ${CMAKE_CURRENT_BINARY_DIR} + DEPENDS ${TESTS} + IMPLICIT_DEPENDS CXX ${TESTS} COMMENT "Generating test runner ${RUNNER}" ) +add_custom_target(generate-test-runner DEPENDS ${RUNNER}) + add_dependencies(xlnt.test generate-test-runner)