diff --git a/CMakeLists.txt b/CMakeLists.txt index e9e649617016..c643de70cac8 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -91,8 +91,27 @@ endif() # Import dependencies ## +## Threads +option(THREADS_PREFER_PTHREAD_FLAG "When enabled, prefer to use the -pthread flag to explicit linking" ON) +find_package(Threads REQUIRED) + +## Complex dependencies add_subdirectory(dependencies) +## Image formats + +# This changes how find_xxx() commands work; the default is to find frameworks before +# standard libraries or headers, but this can be a problem on systems that have Mono +# installed, as it has a framework with the libjpeg and libpng headers present -- so +# CMake finds the headers from Mono but the libraries from Homebrew, and hilarity ensues. +# Setting this to "last" means we always try the standard libraries before the frameworks. +set(CMAKE_FIND_FRAMEWORK LAST) + +# TODO: these really belong in tools/, but CMake has a weird bug with $ +# https://gitlab.kitware.com/cmake/cmake/-/issues/25033 +find_package(JPEG) +find_package(PNG) + ## # Declare options ## @@ -114,7 +133,6 @@ cmake_dependent_option( "Halide_ENABLE_RTTI AND Halide_ENABLE_EXCEPTIONS" OFF ) - ## # Add source directories ## diff --git a/dependencies/CMakeLists.txt b/dependencies/CMakeLists.txt index ea4c5a173493..ef5643fd3b9e 100644 --- a/dependencies/CMakeLists.txt +++ b/dependencies/CMakeLists.txt @@ -1,31 +1,9 @@ -## -# Standard CMake find-module dependencies -## - -set(THREADS_PREFER_PTHREAD_FLAG YES) -find_package(Threads REQUIRED) -set_target_properties(Threads::Threads PROPERTIES IMPORTED_GLOBAL TRUE) - -# TODO(https://github.com/halide/Halide/issues/5633): verify this is still correct / necessary for OpenGLCompute -find_package(OpenGL) -if (TARGET OpenGL::GL) - set_target_properties(OpenGL::GL PROPERTIES IMPORTED_GLOBAL TRUE) -endif () - -find_package(OpenMP) -if (TARGET OpenMP::OpenMP_CXX) - set_target_properties(OpenMP::OpenMP_CXX PROPERTIES IMPORTED_GLOBAL TRUE) -endif () - ## # Third-party dependencies in their own subdirectories ## add_subdirectory(llvm) -add_subdirectory(jpeg) -add_subdirectory(png) - if (TARGET_SPIRV) add_subdirectory(spirv) endif() diff --git a/dependencies/jpeg/CMakeLists.txt b/dependencies/jpeg/CMakeLists.txt deleted file mode 100644 index f9d8f209cbc5..000000000000 --- a/dependencies/jpeg/CMakeLists.txt +++ /dev/null @@ -1,13 +0,0 @@ -if (APPLE) - # This changes how find_xxx() commands work; the default is to find frameworks before - # standard libraries or headers, but this can be a problem on systems that have Mono - # installed, as it has a framework with the libjpeg and libpng headers present -- so - # CMake finds the headers from Mono but the libraries from Homebrew, and hilarity ensues. - # Setting this to "last" means we always try the standard libraries before the frameworks. - set(CMAKE_FIND_FRAMEWORK LAST) -endif () - -find_package(JPEG) -if (TARGET JPEG::JPEG) - set_target_properties(JPEG::JPEG PROPERTIES IMPORTED_GLOBAL TRUE) -endif () \ No newline at end of file diff --git a/dependencies/png/CMakeLists.txt b/dependencies/png/CMakeLists.txt deleted file mode 100644 index 170d1b4c8326..000000000000 --- a/dependencies/png/CMakeLists.txt +++ /dev/null @@ -1,13 +0,0 @@ -if (APPLE) - # This changes how find_xxx() commands work; the default is to find frameworks before - # standard libraries or headers, but this can be a problem on systems that have Mono - # installed, as it has a framework with the libjpeg and libpng headers present -- so - # CMake finds the headers from Mono but the libraries from Homebrew, and hilarity ensues. - # Setting this to "last" means we always try the standard libraries before the frameworks. - set(CMAKE_FIND_FRAMEWORK LAST) -endif () - -find_package(PNG) -if (TARGET PNG::PNG) - set_target_properties(PNG::PNG PROPERTIES IMPORTED_GLOBAL TRUE) -endif () \ No newline at end of file diff --git a/tools/CMakeLists.txt b/tools/CMakeLists.txt index be77d080565b..2d66e5271e35 100644 --- a/tools/CMakeLists.txt +++ b/tools/CMakeLists.txt @@ -15,6 +15,9 @@ target_compile_options(regexp_replace PRIVATE $<$:/wd4996> # Interface target for enabling PNG/JPEG support in Halide ## +# TODO: if/when CMake fixes https://gitlab.kitware.com/cmake/cmake/-/issues/25033 +# then move find_package(PNG/JPEG) here. + add_library(Halide_ImageIO INTERFACE) add_library(Halide::ImageIO ALIAS Halide_ImageIO) set_target_properties(Halide_ImageIO PROPERTIES EXPORT_NAME ImageIO) diff --git a/tutorial/CMakeLists.txt b/tutorial/CMakeLists.txt index 7c1b1f656132..19b72d58c09c 100644 --- a/tutorial/CMakeLists.txt +++ b/tutorial/CMakeLists.txt @@ -1,3 +1,5 @@ +find_package(OpenMP) + configure_file(images/gray.png images/gray.png COPYONLY) configure_file(images/rgb.png images/rgb.png COPYONLY)