File tree Expand file tree Collapse file tree 1 file changed +16
-7
lines changed Expand file tree Collapse file tree 1 file changed +16
-7
lines changed Original file line number Diff line number Diff line change @@ -16,15 +16,24 @@ add_test(NAME cgen_test COMMAND cgen_test)
1616# expansion of flags results in quotes the compiler won't eat,
1717# separating arguments should fix this, but not sure how portable it is.
1818# see also http://stackoverflow.com/questions/9870162/avoid-quoting-in-cmake-add-custom-command
19- separate_arguments (CUSTOM_C_FLAGS UNIX_COMMAND "${CMAKE_C_FLAGS} " )
2019
21- add_custom_target (test_generated
22- COMMAND cgen_test > test_generated${CMAKE_EXECUTABLE_SUFFIX} .c
23- COMMAND ${CMAKE_C_COMPILER} ${CUSTOM_C_FLAGS} test_generated${CMAKE_EXECUTABLE_SUFFIX} .c -c
24- -I${CMAKE_SOURCE_DIR} /include
20+ add_custom_COMMAND (OUTPUT "${CMAKE_CURRENT_BINARY_DIR} /test_generated${CMAKE_EXECUTABLE_SUFFIX} .c"
21+ COMMAND cgen_test > "${CMAKE_CURRENT_BINARY_DIR} /test_generated${CMAKE_EXECUTABLE_SUFFIX} .c"
2522 WORKING_DIRECTORY ${CMAKE_BINARY_DIR} /test /cgen_test
26- BYPRODUCTS test_generated${CMAKE_EXECUTABLE_SUFFIX} .c
2723 DEPENDS cgen_test
28- )
24+ )
25+
26+ if (NOT MSVC )
27+ set (CMAKE_C_FLAGS "${CMAKE_C_FLAGS} -Wno-error=unused-const-variable" )
28+ endif ()
29+ add_library (test_generated_objects STATIC EXCLUDE_FROM_ALL
30+ "${CMAKE_CURRENT_BINARY_DIR} /test_generated${CMAKE_EXECUTABLE_SUFFIX} .c"
31+ )
32+ target_include_directories (test_generated_objects PRIVATE "${PROJECT_SOURCE_DIR} /include" )
33+
34+ add_custom_target (test_generated
35+ COMMAND "${CMAKE_COMMAND} " -E rm -f $<TARGET_OBJECTS:test_generated_objects>
36+ COMMAND "${CMAKE_COMMAND} " --build "${PROJECT_BINARY_DIR} " --target test_generated_objects --config $<CONFIG> --verbose
37+ )
2938
3039add_test (NAME test_generated COMMAND ${CMAKE_COMMAND} --build "${PROJECT_BINARY_DIR} " --target test_generated --config $<CONFIG>)
You can’t perform that action at this time.
0 commit comments