From d3dd83f11b036be7d95493e2e1944bb86f5bb6ae Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?J=C3=A9r=C3=A9mie=20Dumas?= Date: Mon, 15 Oct 2018 12:05:43 -0400 Subject: [PATCH] Set default options based on toplevel project. (#940) * Enable options based on toplevel CMake call. * Update CMakeLists.txt * Update CMakeLists.txt * Update CMakeLists.txt * Update CMakeLists.txt Former-commit-id: 86d3564a14cd9cfcbe50c6dc790424bdab5dc939 --- CMakeLists.txt | 23 +++++++++++++---------- python/CMakeLists.txt | 8 ++++---- tests/CMakeLists.txt | 15 +++++++-------- tutorial/CMakeLists.txt | 18 ++++++++---------- 4 files changed, 32 insertions(+), 32 deletions(-) diff --git a/CMakeLists.txt b/CMakeLists.txt index 40035b6e3..85a71ed93 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -1,20 +1,25 @@ cmake_minimum_required(VERSION 3.1) project(libigl) +# Detects whether this is a top-level project +if(CMAKE_SOURCE_DIR STREQUAL CMAKE_CURRENT_SOURCE_DIR) + set(LIBIGL_TOPLEVEL_PROJECT ON) +else() + set(LIBIGL_TOPLEVEL_PROJECT OFF) +endif() -option(LIBIGL_BUILD_TESTS "Build libigl unit test" OFF) -option(LIBIGL_BUILD_TUTORIALS "Build libigl tutorial" OFF) -option(LIBIGL_BUILD_PYTHON "Build libigl python bindings" OFF) +# Build tests, tutorials and python bindings +option(LIBIGL_BUILD_TESTS "Build libigl unit test" ${LIBIGL_TOPLEVEL_PROJECT}) +option(LIBIGL_BUILD_TUTORIALS "Build libigl tutorial" ${LIBIGL_TOPLEVEL_PROJECT}) +option(LIBIGL_BUILD_PYTHON "Build libigl python bindings" ${LIBIGL_TOPLEVEL_PROJECT}) - -# USE_STATIC_LIBRARY speeds up the generation of multiple binaries, +# USE_STATIC_LIBRARY speeds up the generation of multiple binaries, # at the cost of a longer initial compilation time # (by default, static build is off since libigl is a header-only library) option(LIBIGL_USE_STATIC_LIBRARY "Use LibIGL as static library" ON) # All dependencies that are downloaded as cmake projects and tested on the auto-builds are ON # (by default, all build options are off) -option(LIBIGL_WITH_CGAL "Use CGAL" ON) option(LIBIGL_WITH_COMISO "Use CoMiso" ON) option(LIBIGL_WITH_EMBREE "Use Embree" ON) option(LIBIGL_WITH_OPENGL "Use OpenGL" ON) @@ -28,10 +33,8 @@ option(LIBIGL_WITH_XML "Use XML" ON) option(LIBIGL_WITH_PYTHON "Use Python" ${LIBIGL_BUILD_PYTHON}) ### End -# These ensure that lib*.a are placed in the directory where `cmake -# ../optional/` was issued. -set(CMAKE_LIBRARY_OUTPUT_DIRECTORY ${CMAKE_BINARY_DIR}) -set(CMAKE_ARCHIVE_OUTPUT_DIRECTORY ${CMAKE_BINARY_DIR}) +set(CMAKE_LIBRARY_OUTPUT_DIRECTORY ${CMAKE_BINARY_DIR}) +set(CMAKE_ARCHIVE_OUTPUT_DIRECTORY ${CMAKE_BINARY_DIR}) set(CMAKE_RUNTIME_OUTPUT_DIRECTORY ${CMAKE_BINARY_DIR}) ### conditionally compile certain modules depending on libraries found on the system diff --git a/python/CMakeLists.txt b/python/CMakeLists.txt index 3a8975c2e..8c972b115 100644 --- a/python/CMakeLists.txt +++ b/python/CMakeLists.txt @@ -23,10 +23,10 @@ if(UNIX) endif() endif() -## libigl -if(NOT TARGET igl::core) - list(APPEND CMAKE_MODULE_PATH "${PROJECT_SOURCE_DIR}/../cmake") - include(libigl) +## libigl +if(NOT TARGET igl::core) + list(APPEND CMAKE_MODULE_PATH "${PROJECT_SOURCE_DIR}/../cmake") + include(libigl) endif() ## include pybind diff --git a/tests/CMakeLists.txt b/tests/CMakeLists.txt index e30e06415..8a46a2872 100644 --- a/tests/CMakeLists.txt +++ b/tests/CMakeLists.txt @@ -1,14 +1,13 @@ cmake_minimum_required(VERSION 3.1) project(libigl_tests) -### conditionally compile certain modules depending on libraries found on the system -list(APPEND CMAKE_MODULE_PATH ${PROJECT_SOURCE_DIR}/../cmake) - -### Adding libIGL: choose the path to your local copy libIGL -if(NOT TARGET igl_common) - include(libigl) -else() - include(LibiglDownloadExternal) +list(APPEND CMAKE_MODULE_PATH ${PROJECT_SOURCE_DIR}/../cmake) + +### Adding libIGL: choose the path to your local copy libIGL +if(NOT TARGET igl_common) + include(libigl) +else() + include(LibiglDownloadExternal) endif() ### Download data diff --git a/tutorial/CMakeLists.txt b/tutorial/CMakeLists.txt index 5f8b7a6f6..a985350a3 100644 --- a/tutorial/CMakeLists.txt +++ b/tutorial/CMakeLists.txt @@ -1,16 +1,14 @@ cmake_minimum_required(VERSION 3.1) project(libigl_tutorials) -message(STATUS "CMAKE_C_COMPILER: ${CMAKE_C_COMPILER}") -message(STATUS "CMAKE_CXX_COMPILER: ${CMAKE_CXX_COMPILER}") -### conditionally compile certain modules depending on libraries found on the system -list(APPEND CMAKE_MODULE_PATH ${PROJECT_SOURCE_DIR}/../cmake) - -### Adding libIGL: choose the path to your local copy libIGL -if(NOT TARGET igl_common) - include(libigl) -else() - include(LibiglDownloadExternal) +### conditionally compile certain modules depending on libraries found on the system +list(APPEND CMAKE_MODULE_PATH ${PROJECT_SOURCE_DIR}/../cmake) + +### Adding libIGL: choose the path to your local copy libIGL +if(NOT TARGET igl_common) + include(libigl) +else() + include(LibiglDownloadExternal) endif() ### Download data