Skip to content

Commit

Permalink
nomlib-config.cmake: Clean up handling of NOMLIB_DEPS_ROOT var
Browse files Browse the repository at this point in the history
* Collapse separate handling of NOMLIB_DEPS_PREFIX and
ENV{NOMLIB_DEPS_PREFIX} to one internal var (NOMLIB_DEPS_ROOT)
by appending them at script init, instead of treating the two
vars separately. This helps prevent us from accidentally modifying
the input vars and potentially passing unexpected results back to the
end-user of this module.

* Add validation checks for path existence of the deps prefix before
continuing; this takes the burden off of the end-user of this module.
  • Loading branch information
i8degrees committed Jun 6, 2015
1 parent ab069b7 commit 93c65bd
Showing 1 changed file with 18 additions and 3 deletions.
21 changes: 18 additions & 3 deletions Resources/CMake/nomlib-config.cmake
Original file line number Diff line number Diff line change
Expand Up @@ -67,6 +67,24 @@
# To distribute this file outside of CMake, substitute the full license text
# for the above reference.

set( NOMLIB_DEPS_ROOT "NOTFOUND" )

if( EXISTS ${NOMLIB_DEPS_PREFIX} )
# IMPORTANT: NOMLIB_DEPS_PREFIX will be an external CMake variable within
# this scope, of which **must** already be set by the parent script calling
# FIND_PACKAGE, and should **never** be modified for sake of the parent
# script.
list( APPEND NOMLIB_DEPS_ROOT ${NOMLIB_DEPS_PREFIX} )
endif( EXISTS ${NOMLIB_DEPS_PREFIX} )

if( DEFINED ENV{NOMLIB_DEPS_PREFIX} AND EXISTS ENV{NOMLIB_DEPS_PREFIX} )
list( APPEND NOMLIB_DEPS_ROOT ENV{NOMLIB_DEPS_PREFIX} )
endif( DEFINED ENV{NOMLIB_DEPS_PREFIX} AND EXISTS ENV{NOMLIB_DEPS_PREFIX} )

if( NOMLIB_DEPS_ROOT STREQUAL "NOTFOUND" )
message( FATAL_ERROR "An absolute directory path to the engine's dependencies must be set. See README.md for details." )
endif( NOMLIB_DEPS_ROOT STREQUAL "NOTFOUND" )

if( CMAKE_SYSTEM_NAME STREQUAL "Darwin" )
set( NOM_PLATFORM_OSX TRUE )
elseif( CMAKE_SYSTEM_NAME STREQUAL "Windows" )
Expand Down Expand Up @@ -180,7 +198,6 @@ macro( find_nom_dependency output_var output_name )
find_library( ${output_var} NAMES ${ARGN}
PATHS
${NOMLIB_DEPS_ROOT}
$ENV{NOMLIB_DEPS_ROOT}
${NOM_SEARCH_PREFIX_PATHS}
PATH_SUFFIXES
${NOM_LIBRARY_PATH_SUFFIXES} # osx, *nix
Expand Down Expand Up @@ -215,7 +232,6 @@ if( NOMLIB_CORE_FOUND )
find_path( SDL2_INCLUDE_DIR SDL.h
PATHS
${NOMLIB_DEPS_ROOT}
$ENV{NOMLIB_DEPS_ROOT}
${NOM_SEARCH_PREFIX_PATHS}
PATH_SUFFIXES SDL2/include include
)
Expand Down Expand Up @@ -263,7 +279,6 @@ if( NOMLIB_GUI_FOUND )
find_path( LIBROCKET_INCLUDE_DIR Rocket/Core
PATHS
${NOMLIB_DEPS_ROOT}
$ENV{NOMLIB_DEPS_ROOT}
${NOM_SEARCH_PREFIX_PATHS}
PATH_SUFFIXES libRocket/include include
)
Expand Down

0 comments on commit 93c65bd

Please sign in to comment.