Imported Upstream version 3.1.9
[platform/upstream/Imath.git] / CMakeLists.txt
1 # SPDX-License-Identifier: BSD-3-Clause
2 # Copyright Contributors to the OpenEXR Project.
3
4 cmake_minimum_required(VERSION 3.12)
5
6 if(POLICY CMP0074)
7   cmake_policy(SET CMP0074 NEW)
8 endif()
9
10 if(POLICY CMP0077)
11   # enable variables set outside to override options
12   cmake_policy(SET CMP0077 NEW)
13 endif()
14
15 # Imath version
16
17 project(Imath VERSION 3.1.9 LANGUAGES C CXX)
18
19 set(IMATH_VERSION_RELEASE_TYPE "" CACHE STRING "Extra version tag string for Imath build, such as -dev, -beta1, etc.")
20
21 set(IMATH_VERSION ${Imath_VERSION})
22 set(IMATH_VERSION_API "${Imath_VERSION_MAJOR}_${Imath_VERSION_MINOR}")
23
24 # Library/shared-object version using libtool versioning policy.
25 # See https://www.gnu.org/software/libtool/manual/html_node/Updating-version-info.html
26 #
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
31 #                 ^                     ^  ^ ^
32 #                 |                     |  | |
33 #                 CURRENT               |  | AGE
34 #                                       |  REVISION 
35 #                                       CURRENT
36 # When updating:
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
40 #
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})
46
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)
51
52 message(STATUS "Configure ${IMATH_PACKAGE_NAME}, library API version: ${IMATH_LIB_VERSION}")
53
54 # Config headers and package config files
55 add_subdirectory(config)
56
57 # Utility function for the repeated boilerplate of defining the libraries
58 include(config/LibraryDefine.cmake)
59
60 # Source code is in src/Imath
61 add_subdirectory(src/Imath)
62
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)
66
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")
70
71 option(PYTHON "Set ON to compile PyImath bindings")
72 if (PYTHON)
73   add_subdirectory(src/python)
74 endif()
75
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)
80 endif()
81
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
85 # same protocol
86
87 # These settings will need to be set for your environment,
88 # and then a script such as the example in
89 #
90 # cmake/SampleCTestScript.cmake
91 #
92 # edited and placed into the CI system, then run:
93 #
94 # cmake -S cmake/SampleCTestScript.cmake
95 #
96 # [or whatever you name the file you edit]
97
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)
104 include(CTest)
105 if(BUILD_TESTING AND NOT IMATH_IS_SUBPROJECT)
106   enable_testing()
107   add_subdirectory(src/ImathTest)
108 endif()
109
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
112 # top level.
113 if(NOT IMATH_IS_SUBPROJECT)
114   include(cmake/clang-format.cmake)
115 endif()
116