Skip to content

Commit

Permalink
Reconfigure CMake to build Imath and PyImath optionally.
Browse files Browse the repository at this point in the history
Signed-off-by: Owen Thompson <oxt3479@rit.edu>
  • Loading branch information
oxt3479 committed Jun 23, 2020
1 parent bbb5874 commit 9ec3bb4
Show file tree
Hide file tree
Showing 36 changed files with 353 additions and 1,092 deletions.
76 changes: 41 additions & 35 deletions CMakeLists.txt
Original file line number Diff line number Diff line change
@@ -1,9 +1,7 @@
# SPDX-License-Identifier: BSD-3-Clause
# Copyright Contributors to the OpenEXR Project.

# We require this to get object library link library support and
# combined python 2 + 3 support
if(OPENEXR_BUILD_BOTH_STATIC_SHARED OR ILMBASE_BUILD_BOTH_STATIC_SHARED)
if(IMATH_BUILD_BOTH_STATIC_SHARED OR IMATH_BUILD_BOTH_STATIC_SHARED)
if (${CMAKE_VERSION} VERSION_LESS "3.12.0")
message(FATAL_ERROR "CMake 3.12 or newer is required for object library support when building both static and shared libraries")
endif()
Expand All @@ -16,25 +14,47 @@ if(POLICY CMP0074)
cmake_policy(SET CMP0074 NEW)
endif()

# Hint: This can be set to enable custom find_package
# search paths, probably best to set it when configuring
# on the command line to cmake instead of setting it
# here.
###set(CMAKE_PREFIX_PATH "/prefix")
# we include this first to obtain version numbers from version.cmake
include(config/version.cmake)

project(OpenEXRMetaProject)
#set up our project
project(Imath VERSION ${IMATH_VERSION} LANGUAGES C CXX)

#######################################
#######################################
# This declares all the configuration variables visible
# in cmake-gui or similar and the rest of the global
# project setup
#
# Please look at this file to see what is configurable
#######################################
#######################################
include(config/ImathSetup.cmake)

# An "official" way to make this a super-project
# basically overrides the find_package to not find anything
# for stuff we're including locally
set(as_subproject IlmBase OpenEXR)
macro(find_package)
if(NOT "${ARGV0}" IN_LIST as_subproject)
_find_package(${ARGV})
endif()
endmacro()
# generates config headers, package config files
add_subdirectory(config)

# utility function for the repeated boilerplate of defining
# the libraries
include(config/LibraryDefine.cmake)

#######################################

# Include these modules without enable/disable options
add_subdirectory(Half)
add_subdirectory(Imath)
# Tell CMake where to find the ImathConfig.cmake file. Makes it posible to call
# find_package(Imath) in downstream projects
set(Imath_DIR "${CMAKE_CURRENT_BINARY_DIR}/config" CACHE PATH "" FORCE)
# Add an empty ImathTargets.cmake file for the config to use.
# Can be empty since we already defined the targets in add_subdirectory
file(WRITE "${CMAKE_CURRENT_BINARY_DIR}/config/ImathTargets.cmake" "# Dummy file")


option(PYTHON "Set ON to compile PyImath bindings")
if (PYTHON)
add_subdirectory(python)
endif()

# If you want to use ctest to configure, build and
# upload the results, cmake has builtin support for
Expand All @@ -52,7 +72,7 @@ endmacro()
#
# [or whatever you name the file you edit]
#
#set(CTEST_PROJECT_NAME "OpenEXR")
#set(CTEST_PROJECT_NAME "Imath")
#set(CTEST_NIGHTLY_START_TIME "01:01:01 UTC")
#set(CTEST_DROP_METHOD "http") # there are others...
#set(CTEST_DROP_SITE "open.cdash.org")
Expand All @@ -62,23 +82,9 @@ endmacro()
include(CTest)
if(BUILD_TESTING)
enable_testing()
endif()

#######################################

# Include these two modules without enable/disable options
add_subdirectory(IlmBase)
add_subdirectory(OpenEXR)

# should this just be always on and we conditionally compile what
# is found and warn otherwise? or error out?
option(PYILMBASE_ENABLE "Enables configuration of the PyIlmBase module" ON)
if(PYILMBASE_ENABLE)
if (${CMAKE_VERSION} VERSION_LESS "3.12.0")
message(WARNING ": CMake version ${CMAKE_VERSION} detected, PyIlmBase uses newer features of cmake (>= 3.12), disabling")
else()
add_subdirectory(PyIlmBase)
endif()
add_subdirectory(HalfTest)
add_subdirectory(ImathTest)
endif()

# Including this module will add a `clang-format` target to the build if
Expand Down
2 changes: 1 addition & 1 deletion Half/CMakeLists.txt
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
# SPDX-License-Identifier: BSD-3-Clause
# Copyright Contributors to the OpenEXR Project.

ilmbase_define_library(Half
imath_define_library(Half
PRIV_EXPORT HALF_EXPORTS
CURDIR ${CMAKE_CURRENT_SOURCE_DIR}
SOURCES
Expand Down
40 changes: 0 additions & 40 deletions Half/Makefile.am

This file was deleted.

7 changes: 2 additions & 5 deletions HalfTest/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -13,11 +13,8 @@ add_executable(HalfTest
testToFloat.cpp
)

target_link_libraries(HalfTest IlmBase::Half)
target_link_libraries(HalfTest Half)
set_target_properties(HalfTest PROPERTIES
RUNTIME_OUTPUT_DIRECTORY "${CMAKE_BINARY_DIR}/bin"
)
if(WIN32 AND (BUILD_SHARED_LIBS OR OPENEXR_BUILD_BOTH_STATIC_SHARED))
target_compile_definitions(HalfTest PRIVATE OPENEXR_DLL)
endif()
add_test(NAME IlmBase.Half COMMAND $<TARGET_FILE:HalfTest>)
add_test(NAME Half COMMAND $<TARGET_FILE:HalfTest>)
25 changes: 0 additions & 25 deletions HalfTest/Makefile.am

This file was deleted.

9 changes: 4 additions & 5 deletions Imath/CMakeLists.txt
Original file line number Diff line number Diff line change
@@ -1,23 +1,21 @@
# SPDX-License-Identifier: BSD-3-Clause
# Copyright Contributors to the OpenEXR Project.

ilmbase_define_library(Imath
imath_define_library(Imath
PRIV_EXPORT IMATH_EXPORTS
CURDIR ${CMAKE_CURRENT_SOURCE_DIR}
SOURCES
ImathRandom.cpp
ImathColorAlgo.cpp
ImathFun.cpp
ImathVec.cpp
ImathExc.cpp
ImathMatrixAlgo.cpp
HEADERS
ImathBoxAlgo.h
ImathBox.h
ImathColorAlgo.h
ImathColor.h
ImathEuler.h
ImathExc.h
ImathExport.h
ImathForward.h
ImathFrame.h
Expand Down Expand Up @@ -46,5 +44,6 @@ ilmbase_define_library(Imath
ImathVecAlgo.h
ImathVec.h
DEPENDENCIES
IlmBase::Half IlmBase::IexMath
)
Half IexMath
)

15 changes: 0 additions & 15 deletions Imath/ImathExc.cpp

This file was deleted.

73 changes: 0 additions & 73 deletions Imath/ImathExc.h

This file was deleted.

49 changes: 0 additions & 49 deletions Imath/Makefile.am

This file was deleted.

7 changes: 2 additions & 5 deletions ImathTest/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -27,11 +27,8 @@ add_executable(ImathTest
testVec.cpp
)

target_link_libraries(ImathTest IlmBase::Imath)
target_link_libraries(ImathTest Imath)
set_target_properties(ImathTest PROPERTIES
RUNTIME_OUTPUT_DIRECTORY "${CMAKE_BINARY_DIR}/bin"
)
if(WIN32 AND (BUILD_SHARED_LIBS OR OPENEXR_BUILD_BOTH_STATIC_SHARED))
target_compile_definitions(ImathTest PRIVATE OPENEXR_DLL)
endif()
add_test(NAME IlmBase.Imath COMMAND $<TARGET_FILE:ImathTest>)
add_test(NAME Imath COMMAND $<TARGET_FILE:ImathTest>)

0 comments on commit 9ec3bb4

Please sign in to comment.