From 175d1420fd0160346d3b40c73622e685f7b6eca6 Mon Sep 17 00:00:00 2001 From: Roberto Di Remigio Date: Fri, 3 Aug 2018 16:50:36 -0400 Subject: [PATCH] Fix build with MSYS --- chapter-08/recipe-03/c-example/CMakeLists.txt | 4 ++++ .../c-example/external/upstream/fftw3/CMakeLists.txt | 10 ++++++++-- 2 files changed, 12 insertions(+), 2 deletions(-) diff --git a/chapter-08/recipe-03/c-example/CMakeLists.txt b/chapter-08/recipe-03/c-example/CMakeLists.txt index 1c81152c3..8914542f6 100644 --- a/chapter-08/recipe-03/c-example/CMakeLists.txt +++ b/chapter-08/recipe-03/c-example/CMakeLists.txt @@ -6,6 +6,10 @@ set(CMAKE_C_STANDARD 99) set(CMAKE_C_EXTENSIONS OFF) set(CMAKE_C_STANDARD_REQUIRED ON) +set_property(DIRECTORY PROPERTY EP_BASE ${CMAKE_BINARY_DIR}/subprojects) + +option(FFTW3_FORCE_SUPERBUILD "Always build FFTW3 on our own" OFF) + add_subdirectory(external/upstream) include(ExternalProject) diff --git a/chapter-08/recipe-03/c-example/external/upstream/fftw3/CMakeLists.txt b/chapter-08/recipe-03/c-example/external/upstream/fftw3/CMakeLists.txt index 321208713..037016ae9 100644 --- a/chapter-08/recipe-03/c-example/external/upstream/fftw3/CMakeLists.txt +++ b/chapter-08/recipe-03/c-example/external/upstream/fftw3/CMakeLists.txt @@ -1,10 +1,14 @@ find_package(FFTW3 CONFIG QUIET) -if(FFTW3_FOUND) +if(FFTW3_FOUND AND (NOT FFTW3_FORCE_SUPERBUILD)) get_property(_loc TARGET FFTW3::fftw3 PROPERTY LOCATION) message(STATUS "Found FFTW3: ${_loc} (found version ${FFTW3_VERSION})") add_library(fftw3_external INTERFACE) # dummy else() - message(STATUS "Suitable FFTW3 could not be located. Downloading and building!") + if(FFTW3_FORCE_SUPERBUILD) + message(STATUS "Forcing superbuild of FFTW3.") + else() + message(STATUS "Suitable FFTW3 could not be located. Downloading and building!") + endif() include(ExternalProject) ExternalProject_Add(fftw3_external URL @@ -17,6 +21,8 @@ else() "" CMAKE_ARGS -DCMAKE_INSTALL_PREFIX=${DEPS_INSTALL_PREFIX} + CMAKE_CACHE_ARGS + -DCMAKE_C_FLAGS:STRING=-DWITH_OUR_MALLOC ) include(GNUInstallDirs) set(FFTW3_DIR ${DEPS_INSTALL_PREFIX}/${CMAKE_INSTALL_LIBDIR}/cmake/fftw3