CMakeLists.txt 1.1 KB

123456789101112131415161718192021222324252627282930313233
  1. file(GLOB_RECURSE PRE_HEADERS RELATIVE ${CMAKE_CURRENT_SOURCE_DIR} pre/*.h)
  2. # We need to add the SDK directories on OS X, and perhaps other operating
  3. # systems.
  4. set(gen_cflags)
  5. foreach(gen_include ${CMAKE_C_IMPLICIT_INCLUDE_DIRECTORIES})
  6. list(APPEND gen_cflags ${CMAKE_INCLUDE_FLAG_C}${gen_include})
  7. endforeach()
  8. get_directory_property(gen_cdefs COMPILE_DEFINITIONS)
  9. foreach(gen_cdef ${gen_cdefs})
  10. if(NOT ${gen_cdef} MATCHES "INCLUDE_GENERATED_DECLARATIONS")
  11. list(APPEND gen_cflags "-D${gen_cdef}")
  12. endif()
  13. endforeach()
  14. foreach(hfile ${PRE_HEADERS})
  15. string(REGEX REPLACE ^pre/ post/ post_hfile ${hfile})
  16. get_filename_component(hdir ${CMAKE_CURRENT_BINARY_DIR}/${post_hfile} PATH)
  17. file(MAKE_DIRECTORY ${hdir})
  18. add_custom_command(
  19. OUTPUT ${CMAKE_CURRENT_BINARY_DIR}/${post_hfile}
  20. COMMAND ${CMAKE_C_COMPILER} -std=c99 -E -P
  21. ${CMAKE_CURRENT_SOURCE_DIR}/${hfile}
  22. ${gen_cflags}
  23. -I${LIBUV_INCLUDE_DIRS}
  24. -o ${CMAKE_CURRENT_BINARY_DIR}/${post_hfile})
  25. list(APPEND POST_HEADERS ${post_hfile})
  26. endforeach()
  27. add_custom_target(unittest-headers DEPENDS ${POST_HEADERS})
  28. set_target_properties(unittest-headers PROPERTIES FOLDER test)