From edbf293479a793090e4c62b2e1c408a24dccf449 Mon Sep 17 00:00:00 2001 From: Isabella Muerte <63051+slurps-mad-rips@users.noreply.github.com> Date: Sat, 28 Sep 2019 06:47:20 -0700 Subject: [PATCH] build,cmake: don't try to detect a C++ compiler MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit - 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 Reviewed-By: Saúl Ibarra Corretgé --- CMakeLists.txt | 20 ++++++++++++-------- 1 file changed, 12 insertions(+), 8 deletions(-) diff --git a/CMakeLists.txt b/CMakeLists.txt index 0b62c57e..6c76cf0f 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -1,6 +1,15 @@ # TODO: determine CMAKE_SYSTEM_NAME on OS/390. Currently assumes "OS/390". -cmake_minimum_required(VERSION 2.8.12) -project(libuv) +cmake_minimum_required(VERSION 3.4) +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) 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_link_libraries(uv_a ${uv_libraries}) -option(libuv_buildtests "Build the unit tests when BUILD_TESTING is enabled." ON) - -include(CTest) -if(BUILD_TESTING AND libuv_buildtests) - enable_testing() +if(LIBUV_BUILD_TESTS) add_executable(uv_run_tests ${uv_test_sources}) target_compile_definitions(uv_run_tests PRIVATE ${uv_defines} USING_UV_SHARED=1) @@ -393,7 +398,6 @@ endif() if(UNIX) # Now for some gibbering horrors from beyond the stars... - include(GNUInstallDirs) foreach(x ${uv_libraries}) set(LIBS "${LIBS} -l${x}") endforeach(x)