1 # SPDX-License-Identifier: BSD-3-Clause
2 # Copyright Contributors to the OpenEXR Project.
4 cmake_minimum_required(VERSION 3.12)
7 cmake_policy(SET CMP0074 NEW)
11 # enable variables set outside to override options
12 cmake_policy(SET CMP0077 NEW)
17 project(Imath VERSION 3.1.9 LANGUAGES C CXX)
19 set(IMATH_VERSION_RELEASE_TYPE "" CACHE STRING "Extra version tag string for Imath build, such as -dev, -beta1, etc.")
21 set(IMATH_VERSION ${Imath_VERSION})
22 set(IMATH_VERSION_API "${Imath_VERSION_MAJOR}_${Imath_VERSION_MINOR}")
24 # Library/shared-object version using libtool versioning policy.
25 # See https://www.gnu.org/software/libtool/manual/html_node/Updating-version-info.html
27 # Library API version (CMake's library VERSION attribute) is of the
28 # form CURRENT.REVISION.AGE; the CMake SOVERSION attribute corresonds
29 # to just CURRENT. These produce a .so and a symlink symlink, e.g.:
30 # libImath-3_1.so.29 -> libImath-3_1.so.29.0.0
37 # 1. no API change: CURRENT.REVISION+1.AGE
38 # 2. API added: CURRENT+1.0.AGE+1
39 # 3. API changed: CURRENT+1.0.0
41 set(IMATH_LIBTOOL_CURRENT 29)
42 set(IMATH_LIBTOOL_REVISION 8)
43 set(IMATH_LIBTOOL_AGE 0)
44 set(IMATH_LIB_VERSION "${IMATH_LIBTOOL_CURRENT}.${IMATH_LIBTOOL_REVISION}.${IMATH_LIBTOOL_AGE}")
45 set(IMATH_LIB_SOVERSION ${IMATH_LIBTOOL_CURRENT})
47 # ImathSetup.cmake declares all the configuration variables visible
48 # in cmake-gui or similar and the rest of the global
49 # project setup. Check the context to see what is configurable.
50 include(config/ImathSetup.cmake)
52 message(STATUS "Configure ${IMATH_PACKAGE_NAME}, library API version: ${IMATH_LIB_VERSION}")
54 # Config headers and package config files
55 add_subdirectory(config)
57 # Utility function for the repeated boilerplate of defining the libraries
58 include(config/LibraryDefine.cmake)
60 # Source code is in src/Imath
61 add_subdirectory(src/Imath)
63 # Imath_DIR points to the location of ImathConfig.cmake, which tells
64 # downstream projects where to find Imath, via find_package(Imath).
65 set(Imath_DIR "${CMAKE_CURRENT_BINARY_DIR}/config" CACHE PATH "" FORCE)
67 # Add an empty ImathTargets.cmake file for the config to use. It can
68 # be empty since we already defined the targets in add_subdirectory().
69 file(WRITE "${CMAKE_CURRENT_BINARY_DIR}/config/ImathTargets.cmake" "# Dummy file")
71 option(PYTHON "Set ON to compile PyImath bindings")
73 add_subdirectory(src/python)
76 option(BUILD_DOCS "Set ON to build readthedocs documentation")
77 if (BUILD_DOCS AND NOT IMATH_IS_SUBPROJECT)
78 option(INSTALL_DOCS "Set ON to install html documentation" ON)
79 add_subdirectory(docs)
82 # If you want to use ctest to configure, build and
83 # upload the results, cmake has builtin support for
84 # submitting to CDash, or any server who speaks the
87 # These settings will need to be set for your environment,
88 # and then a script such as the example in
90 # cmake/SampleCTestScript.cmake
92 # edited and placed into the CI system, then run:
94 # cmake -S cmake/SampleCTestScript.cmake
96 # [or whatever you name the file you edit]
98 #set(CTEST_PROJECT_NAME "Imath")
99 #set(CTEST_NIGHTLY_START_TIME "01:01:01 UTC")
100 #set(CTEST_DROP_METHOD "http") # there are others...
101 #set(CTEST_DROP_SITE "open.cdash.org")
102 #set(CTEST_DROP_LOCATION "/submit.php?project=MyProject")
103 #set(CTEST_DROP_SITE_CDASH TRUE)
105 if(BUILD_TESTING AND NOT IMATH_IS_SUBPROJECT)
107 add_subdirectory(src/ImathTest)
110 # Including this module will add a `clang-format` target to the build
111 # if the clang-format executable can be found. Only do this if we are
113 if(NOT IMATH_IS_SUBPROJECT)
114 include(cmake/clang-format.cmake)