Skip to content
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
43 changes: 25 additions & 18 deletions CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,11 @@ project (uvwasi LANGUAGES C)
# This can be a commit hash or tag
set(LIBUV_VERSION v1.37.0)

include(CMakeDependentOption)
cmake_dependent_option(UVWASI_BUILD_TESTS
"Build the unit tests when uvwasi is the root project" ON
"CMAKE_SOURCE_DIR STREQUAL PROJECT_SOURCE_DIR" OFF)

set(CMAKE_RUNTIME_OUTPUT_DIRECTORY ${CMAKE_BINARY_DIR}/out)

if(CMAKE_C_COMPILER_ID MATCHES "AppleClang|Clang|GNU")
Expand Down Expand Up @@ -87,24 +92,26 @@ endif()


## Test targets.
enable_testing()
file(GLOB test_files "test/test-*.c")
foreach(file ${test_files})
get_filename_component(test_name ${file} NAME_WE)
add_executable(${test_name} ${file})
add_test(NAME ${test_name}
COMMAND ${test_name})
target_include_directories(${test_name}
PRIVATE
${PROJECT_SOURCE_DIR}/include)
target_link_libraries(${test_name} PRIVATE uv_a uvwasi_a)
list(APPEND test_list ${test_name})
endforeach()

add_custom_target(check
COMMAND ctest -VV -C Debug -R test-
DEPENDS ${test_list}
)
if(UVWASI_BUILD_TESTS)
enable_testing()
file(GLOB test_files "test/test-*.c")
foreach(file ${test_files})
get_filename_component(test_name ${file} NAME_WE)
add_executable(${test_name} ${file})
add_test(NAME ${test_name}
COMMAND ${test_name})
target_include_directories(${test_name}
PRIVATE
${PROJECT_SOURCE_DIR}/include)
target_link_libraries(${test_name} PRIVATE uv_a uvwasi_a)
list(APPEND test_list ${test_name})
endforeach()

add_custom_target(check
COMMAND ctest -VV -C Debug -R test-
DEPENDS ${test_list}
)
endif()

message(STATUS "summary of build options:

Expand Down