Skip to content

Commit

Permalink
Removes overridden find_package in CMakeLists.txt in favor of reusing…
Browse files Browse the repository at this point in the history
… the generated config files and setting (IlmBase/OpenEXR)_DIR variables Overriding a cmake function is undocumented functionallity and only works one time. Better to avoid if possible.

Signed-off-by: Peter Steneteg <peter@steneteg.se>
  • Loading branch information
petersteneteg authored and cary-ilm committed Aug 9, 2020
1 parent 1343c08 commit 0d13c74
Showing 1 changed file with 15 additions and 12 deletions.
27 changes: 15 additions & 12 deletions CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -24,18 +24,6 @@ endif()

project(OpenEXRMetaProject)


# 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()


# If you want to use ctest to configure, build and
# upload the results, cmake has builtin support for
# submitting to CDash, or any server who speaks the
Expand Down Expand Up @@ -68,8 +56,23 @@ endif()

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

# Tell CMake where to find the IlmBaseConfig.cmake file. Makes it posible to call
# find_package(IlmBase) in downstream projects
set(IlmBase_DIR "${CMAKE_CURRENT_BINARY_DIR}/IlmBase/config" CACHE PATH "" FORCE)
# Add an empty IlmBaseTargets.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}/IlmBase/config/IlmBaseTargets.cmake" "# Dummy file")

add_subdirectory(OpenEXR)

# Tell CMake where to find the OpenEXRConfig.cmake file. Makes it posible to call
# find_package(OpenEXR) in downstream projects
set(OpenEXR_DIR "${CMAKE_CURRENT_BINARY_DIR}/OpenEXR/config" CACHE PATH "" FORCE)
# Add an empty OpenEXRTargets.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}/OpenEXR/config/OpenEXRTargets.cmake" "# Dummy file")

# 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)
Expand Down

0 comments on commit 0d13c74

Please sign in to comment.