Add platform specific cflags to custom compile target test_generated
@@ -19,10 +19,15 @@ add_test(cgen_test cgen_test${CMAKE_EXECUTABLE_SUFFIX})
# in the parser and code generator but due to CMake limitations,
# custom target dependencies only work for Make build targets.
+# expansion of flags results in quotes the compiler won't eat,
+# separating arguments should fix this, but not sure how portable it is.
+# see also http://stackoverflow.com/questions/9870162/avoid-quoting-in-cmake-add-custom-command
+separate_arguments(CUSTOM_C_FLAGS UNIX_COMMAND "${CMAKE_C_FLAGS}")
+
add_custom_target(test_generated
COMMAND ./cgen_test${CMAKE_EXECUTABLE_SUFFIX} > test_generated${CMAKE_EXECUTABLE_SUFFIX}.c
- COMMAND ${CMAKE_C_COMPILER} test_generated${CMAKE_EXECUTABLE_SUFFIX}.c -c -I${CMAKE_SOURCE_DIR}/include
- WORKING_DIRECTORY ${CMAKE_BINARY_DIR}/test/cgen_test
+ COMMAND ${CMAKE_C_COMPILER} ${CUSTOM_C_FLAGS} test_generated${CMAKE_EXECUTABLE_SUFFIX}.c -c
+ -I${CMAKE_SOURCE_DIR}/include WORKING_DIRECTORY ${CMAKE_BINARY_DIR}/test/cgen_test
)
add_dependencies(test_generated cgen_test)
