1
0
mirror of https://github.com/libuv/libuv synced 2025-03-28 21:13:16 +00:00

build,cmake: don't try to detect a C++ compiler

- Bump CMake version to 3.4 so we can eventually use all the
cool things like better generator expression support, and
`target_sources`, and also better MSVC runtime linkage support

- Reorganize includes to be all in one place.

- Rename libuv_buildtests option to LIBUV_BUILD_TESTS. It is disabled
unless BUILD_TESTING is ON *and* libuv is the "root" project. This helps
projects that might use libuv as a git submodule, or as a download that
is then passed to `add_subdirectory`.

Refs: https://github.com/libuv/libuv/pull/2490
PR-URL: https://github.com/libuv/libuv/pull/2495
Reviewed-By: Ben Noordhuis <info@bnoordhuis.nl>
Reviewed-By: Saúl Ibarra Corretgé <s@saghul.net>
This commit is contained in:
Isabella Muerte 2019-09-28 06:47:20 -07:00 committed by Saúl Ibarra Corretgé
parent ae12376dbb
commit edbf293479

View File

@ -1,6 +1,15 @@
# TODO: determine CMAKE_SYSTEM_NAME on OS/390. Currently assumes "OS/390". # TODO: determine CMAKE_SYSTEM_NAME on OS/390. Currently assumes "OS/390".
cmake_minimum_required(VERSION 2.8.12) cmake_minimum_required(VERSION 3.4)
project(libuv) project(libuv LANGUAGES C)
include(CMakePackageConfigHelpers)
include(CMakeDependentOption)
include(GNUInstallDirs)
include(CTest)
cmake_dependent_option(LIBUV_BUILD_TESTS
"Build the unit tests when BUILD_TESTING is enabled and we are the root project" ON
"BUILD_TESTING;CMAKE_SOURCE_DIR STREQUAL PROJECT_SOURCE_DIR" OFF)
if(MSVC) if(MSVC)
list(APPEND uv_cflags /W4) list(APPEND uv_cflags /W4)
@ -369,11 +378,7 @@ target_compile_options(uv_a PRIVATE ${uv_cflags})
target_include_directories(uv_a PUBLIC include PRIVATE src) target_include_directories(uv_a PUBLIC include PRIVATE src)
target_link_libraries(uv_a ${uv_libraries}) target_link_libraries(uv_a ${uv_libraries})
option(libuv_buildtests "Build the unit tests when BUILD_TESTING is enabled." ON) if(LIBUV_BUILD_TESTS)
include(CTest)
if(BUILD_TESTING AND libuv_buildtests)
enable_testing()
add_executable(uv_run_tests ${uv_test_sources}) add_executable(uv_run_tests ${uv_test_sources})
target_compile_definitions(uv_run_tests target_compile_definitions(uv_run_tests
PRIVATE ${uv_defines} USING_UV_SHARED=1) PRIVATE ${uv_defines} USING_UV_SHARED=1)
@ -393,7 +398,6 @@ endif()
if(UNIX) if(UNIX)
# Now for some gibbering horrors from beyond the stars... # Now for some gibbering horrors from beyond the stars...
include(GNUInstallDirs)
foreach(x ${uv_libraries}) foreach(x ${uv_libraries})
set(LIBS "${LIBS} -l${x}") set(LIBS "${LIBS} -l${x}")
endforeach(x) endforeach(x)