56 lines
2.3 KiB
CMake
56 lines
2.3 KiB
CMake
# xo-websock/example/introspect/CMakeLists.txt
|
|
#
|
|
# A webserver that shows its own state in the browser.
|
|
# See .xo-backlog/xo-websock/issues/10.
|
|
|
|
set(SELF_EXE websock_ex_introspect)
|
|
set(SELF_SRCS introspect.cpp)
|
|
|
|
if (XO_ENABLE_EXAMPLES)
|
|
add_executable(${SELF_EXE} ${SELF_SRCS})
|
|
xo_include_options2(${SELF_EXE})
|
|
|
|
xo_self_dependency(${SELF_EXE} websock)
|
|
xo_dependency(${SELF_EXE} xo_indentlog2)
|
|
|
|
# the page, copied beside the executable (introspect.cpp serves it from
|
|
# there). One rule per file, each depending on its source, so editing
|
|
# only the page still refreshes the copy -- a POST_BUILD step would run
|
|
# only when the executable relinks. CONFIGURE_DEPENDS: a new page file
|
|
# is picked up without re-running cmake by hand.
|
|
file(GLOB_RECURSE PAGE_SRCS CONFIGURE_DEPENDS
|
|
${CMAKE_CURRENT_SOURCE_DIR}/mount-origin/*)
|
|
|
|
set(PAGE_COPIES)
|
|
foreach(src ${PAGE_SRCS})
|
|
file(RELATIVE_PATH rel ${CMAKE_CURRENT_SOURCE_DIR} ${src})
|
|
set(dst ${CMAKE_CURRENT_BINARY_DIR}/${rel})
|
|
add_custom_command(OUTPUT ${dst}
|
|
COMMAND ${CMAKE_COMMAND} -E copy_if_different ${src} ${dst}
|
|
DEPENDS ${src})
|
|
list(APPEND PAGE_COPIES ${dst})
|
|
endforeach()
|
|
|
|
add_custom_target(${SELF_EXE}_page ALL DEPENDS ${PAGE_COPIES})
|
|
add_dependencies(${SELF_EXE} ${SELF_EXE}_page)
|
|
|
|
# with -DXO_ENABLE_SOURCE_MAP=ON: the list of type -> source maps of
|
|
# xo-websock and everything it depends on. The program merges them
|
|
# when asked (/dyn/types), so the page can link each object to the code
|
|
# defining its type (.xo-backlog/xo-websock/issues/12)
|
|
xo_type_src_map_list(${CMAKE_CURRENT_BINARY_DIR}/type-maps.json)
|
|
|
|
# the page's browser tests: headless chrome driven over CDP, against a
|
|
# fresh server per test (test/run.sh; .xo-backlog/xo-websock/issues/14).
|
|
# They need node, curl and chrome, which a default build (CI included)
|
|
# does not have -- so off unless asked for
|
|
option(XO_ENABLE_BROWSER_TESTS "run the introspect page's browser tests under ctest" OFF)
|
|
|
|
if (ENABLE_TESTING AND XO_ENABLE_BROWSER_TESTS)
|
|
add_test(NAME browser.introspect
|
|
COMMAND ${CMAKE_CURRENT_SOURCE_DIR}/test/run.sh $<TARGET_FILE:${SELF_EXE}>)
|
|
set_tests_properties(browser.introspect PROPERTIES TIMEOUT 900)
|
|
endif()
|
|
endif()
|
|
|
|
# end CMakeLists.txt
|