cmake: use UVW_ to avoid polluting parent projects
This commit is contained in:
parent
4d54eb946f
commit
fb2f8d9eff
4
.github/workflows/build-macos.yml
vendored
4
.github/workflows/build-macos.yml
vendored
@ -10,12 +10,12 @@ jobs:
|
||||
|
||||
strategy:
|
||||
matrix:
|
||||
mode: [-DBUILD_UVW_SHARED_LIB=ON, -DBUILD_UVW_LIBS=ON, -DBUILD_UVW_LIBS=OFF]
|
||||
mode: [-DUVW_BUILD_SHARED_LIB=ON, -DUVW_BUILD_LIBS=ON, -DUVW_BUILD_LIBS=OFF]
|
||||
|
||||
steps:
|
||||
- uses: actions/checkout@v3
|
||||
- name: Compile tests
|
||||
working-directory: build
|
||||
run: |
|
||||
cmake ${{ matrix.mode }} -DBUILD_TESTING=ON -Dlibuv_buildtests=OFF ..
|
||||
cmake ${{ matrix.mode }} -DUVW_BUILD_TESTING=ON -Dlibuv_buildtests=OFF ..
|
||||
make -j2
|
||||
|
||||
2
.github/workflows/build-ubuntu-20.04.yml
vendored
2
.github/workflows/build-ubuntu-20.04.yml
vendored
@ -16,7 +16,7 @@ jobs:
|
||||
- { pkg: clang, exe: 'clang++', version: 9 }
|
||||
- { pkg: clang, exe: 'clang++', version: 10 }
|
||||
- { pkg: clang, exe: 'clang++', version: 11 }
|
||||
mode: [-DBUILD_UVW_SHARED_LIB=ON, -DBUILD_UVW_LIBS=ON, -DBUILD_UVW_LIBS=OFF]
|
||||
mode: [-DUVW_BUILD_SHARED_LIB=ON, -DUVW_BUILD_LIBS=ON, -DUVW_BUILD_LIBS=OFF]
|
||||
|
||||
runs-on: ubuntu-20.04
|
||||
|
||||
|
||||
2
.github/workflows/build-ubuntu-latest.yml
vendored
2
.github/workflows/build-ubuntu-latest.yml
vendored
@ -15,7 +15,7 @@ jobs:
|
||||
- { pkg: clang, exe: 'clang++', version: 12 }
|
||||
- { pkg: clang, exe: 'clang++', version: 13 }
|
||||
- { pkg: clang, exe: 'clang++', version: 14 }
|
||||
mode: [-DBUILD_UVW_SHARED_LIB=ON, -DBUILD_UVW_LIBS=ON, -DBUILD_UVW_LIBS=OFF]
|
||||
mode: [-DUVW_BUILD_SHARED_LIB=ON, -DUVW_BUILD_LIBS=ON, -DUVW_BUILD_LIBS=OFF]
|
||||
|
||||
runs-on: ubuntu-latest
|
||||
|
||||
|
||||
4
.github/workflows/build-win.yml
vendored
4
.github/workflows/build-win.yml
vendored
@ -11,12 +11,12 @@ jobs:
|
||||
strategy:
|
||||
matrix:
|
||||
generator: [Visual Studio 17 2022]
|
||||
mode: [-DBUILD_UVW_SHARED_LIB=ON, -DBUILD_UVW_LIBS=ON, -DBUILD_UVW_LIBS=OFF]
|
||||
mode: [-DUVW_BUILD_SHARED_LIB=ON, -DUVW_BUILD_LIBS=ON, -DUVW_BUILD_LIBS=OFF]
|
||||
|
||||
steps:
|
||||
- uses: actions/checkout@v3
|
||||
- name: Compile tests
|
||||
working-directory: build
|
||||
run: |
|
||||
cmake -DCMAKE_WINDOWS_EXPORT_ALL_SYMBOLS=TRUE ${{ matrix.mode }} -DBUILD_TESTING=ON -Dlibuv_buildtests=OFF -DCMAKE_CXX_FLAGS=/W1 -G"${{ matrix.generator }}" ..
|
||||
cmake -DCMAKE_WINDOWS_EXPORT_ALL_SYMBOLS=TRUE ${{ matrix.mode }} -DUVW_BUILD_TESTING=ON -Dlibuv_buildtests=OFF -DCMAKE_CXX_FLAGS=/W1 -G"${{ matrix.generator }}" ..
|
||||
cmake --build . -j 2
|
||||
|
||||
2
.github/workflows/coverage.yml
vendored
2
.github/workflows/coverage.yml
vendored
@ -16,7 +16,7 @@ jobs:
|
||||
CXXFLAGS: "-O0 --coverage -fno-inline -fno-inline-small-functions -fno-default-inline"
|
||||
CXX: g++
|
||||
run: |
|
||||
cmake -DBUILD_TESTING=ON -Dlibuv_buildtests=OFF ..
|
||||
cmake -DUVW_BUILD_TESTING=ON -Dlibuv_buildtests=OFF ..
|
||||
make -j4
|
||||
- name: Run tests
|
||||
working-directory: build
|
||||
|
||||
2
.github/workflows/sanitizer.yml
vendored
2
.github/workflows/sanitizer.yml
vendored
@ -21,7 +21,7 @@ jobs:
|
||||
env:
|
||||
CXX: ${{ matrix.compiler }}
|
||||
run: |
|
||||
cmake ${{ matrix.mode }} -DBUILD_TESTING=ON -Dlibuv_buildtests=OFF -DUSE_${{ matrix.sanitizer }}=ON ..
|
||||
cmake ${{ matrix.mode }} -DUVW_BUILD_TESTING=ON -DUVW_USE_${{ matrix.sanitizer }}=ON -Dlibuv_buildtests=OFF ..
|
||||
make -j2
|
||||
- name: Run tests
|
||||
working-directory: build
|
||||
|
||||
4
.github/workflows/tools.yml
vendored
4
.github/workflows/tools.yml
vendored
@ -48,7 +48,7 @@ jobs:
|
||||
working-directory: build
|
||||
run: |
|
||||
export PATH=$PATH:${GITHUB_WORKSPACE}/build/include-what-you-use/build/bin
|
||||
cmake -DBUILD_TESTING=ON \
|
||||
cmake -DUVW_BUILD_TESTING=ON \
|
||||
-Dlibuv_buildtests=OFF \
|
||||
-DCMAKE_C_COMPILER=clang-$LLVM \
|
||||
-DCMAKE_CXX_COMPILER=clang++-$LLVM \
|
||||
@ -69,7 +69,7 @@ jobs:
|
||||
env:
|
||||
CXX: clang++
|
||||
run: |
|
||||
cmake -DBUILD_TESTING=ON -Dlibuv_buildtests=OFF -DUSE_CLANG_TIDY=ON ..
|
||||
cmake -DUVW_BUILD_TESTING=ON -DUVW_USE_CLANG_TIDY=ON -Dlibuv_buildtests=OFF ..
|
||||
make -j4
|
||||
- name: Run tests
|
||||
working-directory: build
|
||||
|
||||
@ -31,23 +31,23 @@ if(NOT CMAKE_BUILD_TYPE)
|
||||
set(CMAKE_BUILD_TYPE Debug)
|
||||
endif()
|
||||
|
||||
option(USE_LIBCPP "Use libc++ by adding -stdlib=libc++ flag if available." ON)
|
||||
option(USE_ASAN "Use address sanitizer by adding -fsanitize=address -fno-omit-frame-pointer flags" OFF)
|
||||
option(USE_UBSAN "Use address sanitizer by adding -fsanitize=undefined -fno-sanitize-recover=all -fno-omit-frame-pointer flags" OFF)
|
||||
option(USE_CLANG_TIDY "Enable static analysis with clang-tidy" OFF)
|
||||
option(BUILD_UVW_LIBS "Prepare targets for static library rather than for a header-only library." OFF)
|
||||
option(BUILD_UVW_SHARED_LIB "Prepare targets for shared library rather than for a header-only library." OFF)
|
||||
option(FIND_LIBUV "Try finding libuv library development files in the system" OFF)
|
||||
option(UVW_USE_LIBCPP "Use libc++ by adding -stdlib=libc++ flag if available." ON)
|
||||
option(UVW_USE_ASAN "Use address sanitizer by adding -fsanitize=address -fno-omit-frame-pointer flags" OFF)
|
||||
option(UVW_USE_UBSAN "Use address sanitizer by adding -fsanitize=undefined -fno-sanitize-recover=all -fno-omit-frame-pointer flags" OFF)
|
||||
option(UVW_USE_CLANG_TIDY "Enable static analysis with clang-tidy" OFF)
|
||||
option(UVW_BUILD_LIBS "Prepare targets for static library rather than for a header-only library." OFF)
|
||||
option(UVW_BUILD_SHARED_LIB "Prepare targets for shared library rather than for a header-only library." OFF)
|
||||
option(UVW_FIND_LIBUV "Try finding libuv library development files in the system" OFF)
|
||||
|
||||
if(BUILD_UVW_SHARED_LIB)
|
||||
set(BUILD_UVW_LIBS BOOL:ON)
|
||||
if(UVW_BUILD_SHARED_LIB)
|
||||
set(UVW_BUILD_LIBS BOOL:ON)
|
||||
endif()
|
||||
|
||||
#
|
||||
# Compiler stuff
|
||||
#
|
||||
|
||||
if(NOT WIN32 AND USE_LIBCPP)
|
||||
if(NOT WIN32 AND UVW_USE_LIBCPP)
|
||||
include(CheckCXXSourceCompiles)
|
||||
include(CMakePushCheckState)
|
||||
|
||||
@ -58,34 +58,34 @@ if(NOT WIN32 AND USE_LIBCPP)
|
||||
check_cxx_source_compiles("
|
||||
#include<type_traits>
|
||||
int main() { return std::is_same_v<int, char>; }
|
||||
" HAS_LIBCPP)
|
||||
" UVW_HAS_LIBCPP)
|
||||
|
||||
if(NOT HAS_LIBCPP)
|
||||
message(WARNING "The option USE_LIBCPP is set (by default) but libc++ is not available. The flag will not be added to the target.")
|
||||
if(NOT UVW_HAS_LIBCPP)
|
||||
message(WARNING "The option UVW_USE_LIBCPP is set (by default) but libc++ is not available. The flag will not be added to the target.")
|
||||
endif()
|
||||
|
||||
cmake_pop_check_state()
|
||||
endif()
|
||||
|
||||
if(USE_CLANG_TIDY)
|
||||
find_program(CLANG_TIDY_EXECUTABLE "clang-tidy")
|
||||
if(UVW_USE_CLANG_TIDY)
|
||||
find_program(UVW_CLANG_TIDY_EXECUTABLE "clang-tidy")
|
||||
|
||||
if(NOT CLANG_TIDY_EXECUTABLE)
|
||||
message(VERBOSE "The option USE_CLANG_TIDY is set but clang-tidy executable is not available.")
|
||||
if(NOT UVW_CLANG_TIDY_EXECUTABLE)
|
||||
message(VERBOSE "The option UVW_USE_CLANG_TIDY is set but clang-tidy executable is not available.")
|
||||
endif()
|
||||
endif()
|
||||
|
||||
# Required minimal libuv version
|
||||
set(LIBUV_VERSION 1.49.0)
|
||||
set(UVW_LIBUV_VERSION 1.49.0)
|
||||
|
||||
function(fetch_libuv)
|
||||
if (FETCH_LIBUV)
|
||||
if (UVW_FETCH_LIBUV)
|
||||
include(FetchContent)
|
||||
|
||||
FetchContent_Declare(
|
||||
libuv
|
||||
GIT_REPOSITORY https://github.com/libuv/libuv.git
|
||||
GIT_TAG "v${LIBUV_VERSION}"
|
||||
GIT_TAG "v${UVW_LIBUV_VERSION}"
|
||||
GIT_SHALLOW 1
|
||||
)
|
||||
|
||||
@ -96,23 +96,24 @@ function(fetch_libuv)
|
||||
add_subdirectory(${libuv_SOURCE_DIR} ${libuv_BINARY_DIR} EXCLUDE_FROM_ALL)
|
||||
endif()
|
||||
|
||||
if(BUILD_UVW_SHARED_LIB)
|
||||
if(UVW_BUILD_SHARED_LIB)
|
||||
add_library(uv::uv-shared ALIAS uv)
|
||||
set_target_properties(uv PROPERTIES POSITION_INDEPENDENT_CODE 1)
|
||||
else()
|
||||
add_library(uv::uv-static ALIAS uv_a)
|
||||
set_target_properties(uv_a PROPERTIES POSITION_INDEPENDENT_CODE 1)
|
||||
endif()
|
||||
endif(FETCH_LIBUV)
|
||||
endif(UVW_FETCH_LIBUV)
|
||||
endfunction()
|
||||
|
||||
function(use_libuv)
|
||||
set(FETCH_LIBUV_DEFAULT ON)
|
||||
if (FIND_LIBUV)
|
||||
set(UVW_FETCH_LIBUV_DEFAULT ON)
|
||||
|
||||
if (UVW_FIND_LIBUV)
|
||||
find_package(libuv ${LIBUV_VERSION} QUIET)
|
||||
if (libuv_FOUND)
|
||||
add_library(uv::uv-shared ALIAS uv)
|
||||
set(FETCH_LIBUV_DEFAULT OFF)
|
||||
set(UVW_FETCH_LIBUV_DEFAULT OFF)
|
||||
message(STATUS "libuv ${libuv_VERSION} found via cmake")
|
||||
else(libuv_FOUND)
|
||||
find_package(PkgConfig QUIET)
|
||||
@ -120,14 +121,15 @@ function(use_libuv)
|
||||
pkg_check_modules(libuv IMPORTED_TARGET libuv>=${LIBUV_VERSION})
|
||||
if (libuv_FOUND)
|
||||
add_library(uv::uv-shared ALIAS PkgConfig::libuv)
|
||||
set(FETCH_LIBUV_DEFAULT OFF)
|
||||
set(UVW_FETCH_LIBUV_DEFAULT OFF)
|
||||
message(STATUS "libuv ${libuv_VERSION} found via pkg-config")
|
||||
endif(libuv_FOUND)
|
||||
endif(PkgConfig_FOUND)
|
||||
endif(libuv_FOUND)
|
||||
endif(FIND_LIBUV)
|
||||
endif(UVW_FIND_LIBUV)
|
||||
|
||||
option(UVW_FETCH_LIBUV "Fetch the libuv repo using CMake FetchContent facility" ${UVW_FETCH_LIBUV_DEFAULT})
|
||||
|
||||
option(FETCH_LIBUV "Fetch the libuv repo using CMake FetchContent facility" ${FETCH_LIBUV_DEFAULT})
|
||||
fetch_libuv()
|
||||
endfunction()
|
||||
|
||||
@ -137,7 +139,7 @@ endfunction()
|
||||
|
||||
include(GNUInstallDirs)
|
||||
|
||||
if(BUILD_UVW_LIBS)
|
||||
if(UVW_BUILD_LIBS)
|
||||
use_libuv()
|
||||
|
||||
add_subdirectory(src)
|
||||
@ -155,25 +157,25 @@ else()
|
||||
$<INSTALL_INTERFACE:${CMAKE_INSTALL_INCLUDEDIR}>
|
||||
)
|
||||
|
||||
if(USE_ASAN)
|
||||
if(UVW_USE_ASAN)
|
||||
target_compile_options(uvw INTERFACE $<$<CONFIG:Debug>:-fsanitize=address -fno-omit-frame-pointer>)
|
||||
target_link_libraries(uvw INTERFACE $<$<CONFIG:Debug>:-fsanitize=address>)
|
||||
endif()
|
||||
|
||||
if(USE_UBSAN)
|
||||
if(UVW_USE_UBSAN)
|
||||
target_compile_options(uvw INTERFACE $<$<CONFIG:Debug>:-fsanitize=undefined -fno-sanitize-recover=all -fno-omit-frame-pointer>)
|
||||
target_link_libraries(uvw INTERFACE $<$<CONFIG:Debug>:-fsanitize=undefined>)
|
||||
endif()
|
||||
|
||||
if(CLANG_TIDY_EXECUTABLE)
|
||||
set(CMAKE_CXX_CLANG_TIDY "${CLANG_TIDY_EXECUTABLE};--config-file=${uvw_SOURCE_DIR}/.clang-tidy;--header-filter=${uvw_SOURCE_DIR}/src/uvw/.*")
|
||||
if(UVW_CLANG_TIDY_EXECUTABLE)
|
||||
set(CMAKE_CXX_CLANG_TIDY "${UVW_CLANG_TIDY_EXECUTABLE};--config-file=${uvw_SOURCE_DIR}/.clang-tidy;--header-filter=${uvw_SOURCE_DIR}/src/uvw/.*")
|
||||
endif()
|
||||
|
||||
if(HAS_LIBCPP)
|
||||
if(UVW_HAS_LIBCPP)
|
||||
target_compile_options(uvw BEFORE INTERFACE -stdlib=libc++)
|
||||
endif()
|
||||
|
||||
file(GLOB HEADERS src/uvw/*.h src/uvw/*.hpp src/uvw/*.cpp)
|
||||
file(GLOB HEADERS src/uvw/*.h src/uvw/*.hpp)
|
||||
endif()
|
||||
|
||||
#
|
||||
@ -198,7 +200,7 @@ install(
|
||||
# Install targets
|
||||
#
|
||||
|
||||
if (BUILD_UVW_LIBS)
|
||||
if (UVW_BUILD_LIBS)
|
||||
set_target_properties(
|
||||
uvw PROPERTIES
|
||||
VERSION ${UVW_VERSION_MAJOR}.${UVW_VERSION_MINOR}.${UVW_VERSION_PATCH}
|
||||
@ -220,26 +222,26 @@ install(
|
||||
ARCHIVE DESTINATION ${CMAKE_INSTALL_LIBDIR}
|
||||
)
|
||||
|
||||
if(FETCH_LIBUV AND BUILD_UVW_LIBS)
|
||||
if(UVW_FETCH_LIBUV AND UVW_BUILD_LIBS)
|
||||
# libuv is only fetched when both above conditions are true
|
||||
install(DIRECTORY ${libuv_SOURCE_DIR}/include/ DESTINATION ${CMAKE_INSTALL_INCLUDEDIR}/uvw/uv/include)
|
||||
if (BUILD_UVW_SHARED_LIB)
|
||||
if (UVW_BUILD_SHARED_LIB)
|
||||
install(TARGETS uv EXPORT uvwConfig LIBRARY DESTINATION ${CMAKE_INSTALL_LIBDIR}/uvw)
|
||||
else()
|
||||
install(TARGETS uv_a EXPORT uvwConfig ARCHIVE DESTINATION ${CMAKE_INSTALL_LIBDIR}/uvw)
|
||||
endif()
|
||||
endif(FETCH_LIBUV AND BUILD_UVW_LIBS)
|
||||
endif(UVW_FETCH_LIBUV AND UVW_BUILD_LIBS)
|
||||
|
||||
export(EXPORT uvwConfig)
|
||||
|
||||
### Testing
|
||||
|
||||
option(BUILD_TESTING "Enable testing with ctest." OFF)
|
||||
option(UVW_BUILD_TESTING "Enable testing with ctest." OFF)
|
||||
|
||||
if(BUILD_TESTING)
|
||||
option(FIND_GTEST_PACKAGE "Enable finding gtest package." OFF)
|
||||
if(UVW_BUILD_TESTING)
|
||||
option(UVW_FIND_GTEST_PACKAGE "Enable finding gtest package." OFF)
|
||||
|
||||
if (NOT BUILD_UVW_LIBS)
|
||||
if (NOT UVW_BUILD_LIBS)
|
||||
use_libuv()
|
||||
endif()
|
||||
|
||||
@ -251,9 +253,9 @@ endif()
|
||||
# Documentation
|
||||
#
|
||||
|
||||
option(BUILD_DOCS "Enable building with documentation." OFF)
|
||||
option(UVW_BUILD_DOCS "Enable building with documentation." OFF)
|
||||
|
||||
if(BUILD_DOCS)
|
||||
if(UVW_BUILD_DOCS)
|
||||
find_package(Doxygen 1.10)
|
||||
|
||||
if(DOXYGEN_FOUND)
|
||||
|
||||
@ -24,7 +24,7 @@
|
||||
"description": "Common (non-OS specific) mode for development",
|
||||
"inherits": "cmake-pedantic",
|
||||
"cacheVariables": {
|
||||
"BUILD_TESTING": true,
|
||||
"UVW_BUILD_TESTING": true,
|
||||
"libuv_buildtests": false
|
||||
}
|
||||
},
|
||||
|
||||
@ -140,7 +140,7 @@ When used through `CMake`, the `uvw::uvw` target is exported for convenience.
|
||||
|
||||
### Static
|
||||
|
||||
To use `uvw` as a compiled library, set the `BUILD_UVW_LIBS` options in cmake
|
||||
To use `uvw` as a compiled library, set the `UVW_BUILD_LIBS` options in cmake
|
||||
before including the project.<br/>
|
||||
This option triggers the generation of a targets named
|
||||
`uvw::uvw-static`. The matching version of `libuv` is also
|
||||
@ -209,7 +209,7 @@ else.
|
||||
To build the tests:
|
||||
|
||||
* `$ cd build`
|
||||
* `$ cmake .. -DBUILD_TESTING=ON`
|
||||
* `$ cmake .. -DUVW_BUILD_TESTING=ON`
|
||||
* `$ make`
|
||||
* `$ ctest -j4 -R uvw`
|
||||
|
||||
|
||||
@ -42,17 +42,17 @@ function(add_uvw_library LIB_NAME)
|
||||
$<INSTALL_INTERFACE:${CMAKE_INSTALL_INCLUDEDIR}>
|
||||
)
|
||||
|
||||
if(USE_ASAN)
|
||||
if(UVW_USE_ASAN)
|
||||
target_compile_options(${LIB_NAME} PUBLIC $<$<CONFIG:Debug>:-fsanitize=address -fno-omit-frame-pointer>)
|
||||
target_link_libraries(${LIB_NAME} PUBLIC $<$<CONFIG:Debug>:-fsanitize=address>)
|
||||
endif()
|
||||
|
||||
if(USE_UBSAN)
|
||||
if(UVW_USE_UBSAN)
|
||||
target_compile_options(${LIB_NAME} PUBLIC $<$<CONFIG:Debug>:-fsanitize=undefined -fno-sanitize-recover=all -fno-omit-frame-pointer>)
|
||||
target_link_libraries(${LIB_NAME} PUBLIC $<$<CONFIG:Debug>:-fsanitize=undefined>)
|
||||
endif()
|
||||
|
||||
if(HAS_LIBCPP)
|
||||
if(UVW_HAS_LIBCPP)
|
||||
target_compile_options(${LIB_NAME} BEFORE PUBLIC -stdlib=libc++)
|
||||
endif()
|
||||
endfunction()
|
||||
@ -61,7 +61,7 @@ endfunction()
|
||||
# Build and install libraries
|
||||
#
|
||||
|
||||
if (BUILD_UVW_SHARED_LIB)
|
||||
if (UVW_BUILD_SHARED_LIB)
|
||||
add_library(uvw SHARED)
|
||||
add_library(uvw::uvw-shared ALIAS uvw)
|
||||
# If libuv is not fetched by ourselves, it's the caller's responsibility to make sure of the linkage.
|
||||
|
||||
@ -7,7 +7,7 @@ include(FetchContent)
|
||||
set(THREADS_PREFER_PTHREAD_FLAG ON)
|
||||
find_package(Threads REQUIRED)
|
||||
|
||||
if(FIND_GTEST_PACKAGE)
|
||||
if(UVW_FIND_GTEST_PACKAGE)
|
||||
find_package(GTest REQUIRED)
|
||||
else()
|
||||
FetchContent_Declare(
|
||||
@ -19,18 +19,22 @@ else()
|
||||
|
||||
FetchContent_GetProperties(googletest)
|
||||
|
||||
if(NOT googletest_POPULATED)
|
||||
FetchContent_Populate(googletest)
|
||||
set(gtest_force_shared_crt ON CACHE BOOL "" FORCE)
|
||||
add_subdirectory(${googletest_SOURCE_DIR} ${googletest_BINARY_DIR} EXCLUDE_FROM_ALL)
|
||||
endif()
|
||||
FetchContent_MakeAvailable(googletest)
|
||||
|
||||
add_library(GTest::Main ALIAS gtest_main)
|
||||
|
||||
target_compile_features(gtest PUBLIC cxx_std_17)
|
||||
set_target_properties(gtest PROPERTIES CXX_CLANG_TIDY "")
|
||||
|
||||
target_compile_features(gtest_main PUBLIC cxx_std_17)
|
||||
set_target_properties(gtest_main PROPERTIES CXX_CLANG_TIDY "")
|
||||
|
||||
target_compile_features(gmock PUBLIC cxx_std_17)
|
||||
set_target_properties(gmock PROPERTIES CXX_CLANG_TIDY "")
|
||||
|
||||
target_compile_features(gmock_main PUBLIC cxx_std_17)
|
||||
set_target_properties(gmock_main PROPERTIES CXX_CLANG_TIDY "")
|
||||
|
||||
if(CMAKE_SYSTEM_NAME MATCHES OpenBSD)
|
||||
target_compile_options(gtest PRIVATE -Wno-error)
|
||||
@ -41,7 +45,7 @@ if(WIN32)
|
||||
set(WINSOCK2 ws2_32)
|
||||
endif()
|
||||
|
||||
function(ADD_UVW_TEST TEST_NAME TEST_SOURCE)
|
||||
function(UVW_ADD_TEST TEST_NAME TEST_SOURCE)
|
||||
add_executable(${TEST_NAME} ${TEST_SOURCE})
|
||||
|
||||
target_link_libraries(
|
||||
@ -69,16 +73,16 @@ function(ADD_UVW_TEST TEST_NAME TEST_SOURCE)
|
||||
add_test(NAME uvw_${TEST_NAME} COMMAND $<TARGET_FILE:${TEST_NAME}>)
|
||||
endfunction()
|
||||
|
||||
function(ADD_UVW_DIR_TEST TEST_NAME TEST_SOURCE)
|
||||
ADD_UVW_TEST(${TEST_NAME} ${TEST_SOURCE})
|
||||
function(UVW_ADD_DIR_TEST TEST_NAME TEST_SOURCE)
|
||||
UVW_ADD_TEST(${TEST_NAME} ${TEST_SOURCE})
|
||||
string(TOUPPER "${TEST_NAME}" TEST_NAME_UPPER)
|
||||
set(TEST_DIR_VAR "TARGET_${TEST_NAME_UPPER}_DIR")
|
||||
file(MAKE_DIRECTORY ${CMAKE_CURRENT_BINARY_DIR}/${TEST_NAME}_data)
|
||||
target_compile_definitions(${TEST_NAME} PRIVATE ${TEST_DIR_VAR}="${TEST_NAME}_data")
|
||||
endfunction()
|
||||
|
||||
function(ADD_UVW_LIB_TEST TEST_NAME TEST_SOURCE)
|
||||
ADD_UVW_TEST(${TEST_NAME} ${TEST_SOURCE})
|
||||
function(UVW_ADD_LIB_TEST TEST_NAME TEST_SOURCE)
|
||||
UVW_ADD_TEST(${TEST_NAME} ${TEST_SOURCE})
|
||||
target_link_libraries(${TEST_NAME} PRIVATE ${CMAKE_DL_LIBS})
|
||||
target_compile_definitions(${TEST_NAME} PRIVATE TARGET_LIB_SO="$<TARGET_FILE:fake>")
|
||||
endfunction()
|
||||
@ -87,39 +91,39 @@ add_library(fake SHARED fake.cpp)
|
||||
|
||||
# List of available targets
|
||||
|
||||
option(BUILD_DNS_TEST "Build DNS test." OFF)
|
||||
option(UVW_BUILD_DNS_TEST "Build DNS test." OFF)
|
||||
|
||||
ADD_UVW_TEST(main main.cpp)
|
||||
ADD_UVW_TEST(async uvw/async.cpp)
|
||||
ADD_UVW_TEST(check uvw/check.cpp)
|
||||
ADD_UVW_TEST(emitter uvw/emitter.cpp)
|
||||
ADD_UVW_DIR_TEST(file_req uvw/file_req.cpp)
|
||||
ADD_UVW_DIR_TEST(fs_event uvw/fs_event.cpp)
|
||||
ADD_UVW_DIR_TEST(fs_req uvw/fs_req.cpp)
|
||||
ADD_UVW_TEST(handle uvw/handle.cpp)
|
||||
ADD_UVW_TEST(idle uvw/idle.cpp)
|
||||
ADD_UVW_LIB_TEST(lib uvw/lib.cpp)
|
||||
ADD_UVW_TEST(loop uvw/loop.cpp)
|
||||
ADD_UVW_DIR_TEST(pipe uvw/pipe.cpp)
|
||||
ADD_UVW_TEST(prepare uvw/prepare.cpp)
|
||||
ADD_UVW_TEST(process uvw/process.cpp)
|
||||
ADD_UVW_TEST(request uvw/request.cpp)
|
||||
ADD_UVW_TEST(resource uvw/resource.cpp)
|
||||
ADD_UVW_TEST(signal uvw/signal.cpp)
|
||||
ADD_UVW_TEST(stream uvw/stream.cpp)
|
||||
ADD_UVW_TEST(tcp uvw/tcp.cpp)
|
||||
ADD_UVW_TEST(thread uvw/thread.cpp)
|
||||
ADD_UVW_TEST(timer uvw/timer.cpp)
|
||||
ADD_UVW_TEST(tty uvw/tty.cpp)
|
||||
ADD_UVW_TEST(udp uvw/udp.cpp)
|
||||
ADD_UVW_TEST(uv_type uvw/uv_type.cpp)
|
||||
ADD_UVW_TEST(util uvw/util.cpp)
|
||||
ADD_UVW_TEST(work uvw/work.cpp)
|
||||
UVW_ADD_TEST(main main.cpp)
|
||||
UVW_ADD_TEST(async uvw/async.cpp)
|
||||
UVW_ADD_TEST(check uvw/check.cpp)
|
||||
UVW_ADD_TEST(emitter uvw/emitter.cpp)
|
||||
UVW_ADD_DIR_TEST(file_req uvw/file_req.cpp)
|
||||
UVW_ADD_DIR_TEST(fs_event uvw/fs_event.cpp)
|
||||
UVW_ADD_DIR_TEST(fs_req uvw/fs_req.cpp)
|
||||
UVW_ADD_TEST(handle uvw/handle.cpp)
|
||||
UVW_ADD_TEST(idle uvw/idle.cpp)
|
||||
UVW_ADD_LIB_TEST(lib uvw/lib.cpp)
|
||||
UVW_ADD_TEST(loop uvw/loop.cpp)
|
||||
UVW_ADD_DIR_TEST(pipe uvw/pipe.cpp)
|
||||
UVW_ADD_TEST(prepare uvw/prepare.cpp)
|
||||
UVW_ADD_TEST(process uvw/process.cpp)
|
||||
UVW_ADD_TEST(request uvw/request.cpp)
|
||||
UVW_ADD_TEST(resource uvw/resource.cpp)
|
||||
UVW_ADD_TEST(signal uvw/signal.cpp)
|
||||
UVW_ADD_TEST(stream uvw/stream.cpp)
|
||||
UVW_ADD_TEST(tcp uvw/tcp.cpp)
|
||||
UVW_ADD_TEST(thread uvw/thread.cpp)
|
||||
UVW_ADD_TEST(timer uvw/timer.cpp)
|
||||
UVW_ADD_TEST(tty uvw/tty.cpp)
|
||||
UVW_ADD_TEST(udp uvw/udp.cpp)
|
||||
UVW_ADD_TEST(uv_type uvw/uv_type.cpp)
|
||||
UVW_ADD_TEST(util uvw/util.cpp)
|
||||
UVW_ADD_TEST(work uvw/work.cpp)
|
||||
|
||||
if(NOT CMAKE_SYSTEM_NAME MATCHES OpenBSD)
|
||||
ADD_UVW_DIR_TEST(file_req_sendfile uvw/file_req_sendfile.cpp)
|
||||
UVW_ADD_DIR_TEST(file_req_sendfile uvw/file_req_sendfile.cpp)
|
||||
endif()
|
||||
|
||||
if(BUILD_DNS_TEST)
|
||||
ADD_UVW_TEST(dns uvw/dns.cpp)
|
||||
if(UVW_BUILD_DNS_TEST)
|
||||
UVW_ADD_TEST(dns uvw/dns.cpp)
|
||||
endif()
|
||||
|
||||
Loading…
Reference in New Issue
Block a user