]> git.mxchange.org Git - flightgear.git/commitdiff
Improve error message when SimGear headers are missing/incomplete.
authorThorstenB <brehmt@gmail.com>
Sun, 26 Aug 2012 13:28:51 +0000 (15:28 +0200)
committerThorstenB <brehmt@gmail.com>
Sun, 26 Aug 2012 13:28:51 +0000 (15:28 +0200)
Also avoid CMake errors when files are missing.

CMakeLists.txt
CMakeModules/FindSimGear.cmake

index d0ef8c4fda9f1a37a34289dfc0a3657fb194438a..9550205374d9e47ce5212f0a762c79f894780341 100644 (file)
@@ -37,7 +37,10 @@ set(CMAKE_MINSIZEREL_POSTFIX     ""  CACHE STRING "add a postfix, usually empty
 
 # read 'version' file into a variable (stripping any newlines or spaces)
 file(READ version versionFile)
-string(STRIP ${versionFile} FLIGHTGEAR_VERSION)
+if (NOT versionFile)
+    message(FATAL_ERROR "Unable to determine FlightGear version. Version file is missing.")
+endif()
+string(STRIP "${versionFile}" FLIGHTGEAR_VERSION)
 
 # FlightGear packaging (to build a source tarball)
 include( ConfigureCPack )
@@ -60,7 +63,7 @@ endif(NOT CMAKE_BUILD_TYPE)
 if(NOT "$ENV{BUILD_ID}" STREQUAL "")
     set(HUDSON_BUILD_ID $ENV{BUILD_ID})
     set(HUDSON_BUILD_NUMBER $ENV{BUILD_NUMBER})
-    message(STATUS "running under Hudson, build-number is ${HUDSON_BUILD_NUMBER}")
+    message(STATUS "running under Hudson/Jenkins, build-number is ${HUDSON_BUILD_NUMBER}")
 else()
     set(HUDSON_BUILD_NUMBER 0)
     set(HUDSON_BUILD_ID "none")
@@ -91,19 +94,22 @@ else()
     set(REVISION "none")
 endif()
 
-option(LOGGING           "Set to OFF to build FlightGear without logging" ON)
+# FlightGear build options
+option(LOGGING           "Set to ON to build FlightGear with logging support (default)" ON)
 option(SP_FDMS           "Set to ON to build FlightGear with special-purpose FDMs" OFF)
 option(ENABLE_UIUC_MODEL "Set to ON to build FlightGear with UIUCModel FDM" OFF)
 option(ENABLE_LARCSIM    "Set to ON to build FlightGear with LaRCsim FDM" OFF)
-option(ENABLE_YASIM      "Set to ON to build FlightGear with YASIM FDM" ON)
-option(ENABLE_JSBSIM     "Set to ON to build FlightGear with JSBSim FDM" ON)
-option(ENABLE_FGADMIN    "Set to ON to build FlightGear with FGADMIN" ON)
+option(ENABLE_YASIM      "Set to ON to build FlightGear with YASIM FDM (default)" ON)
+option(ENABLE_JSBSIM     "Set to ON to build FlightGear with JSBSim FDM (default)" ON)
 option(EVENT_INPUT       "Set to ON to build FlightGear with event-based Input support" ${EVENT_INPUT_DEFAULT})
-option(ENABLE_LIBSVN     "Set to ON to build FlightGear/terrasync with libsvnclient support" ON)
-option(ENABLE_RTI        "Set to ON to build SimGear with RTI support" OFF)
-option(WITH_FGPANEL      "Set to ON to build the fgpanel application" ON)
-option(JPEG_FACTORY      "Enable JPEG-factory support" OFF)
-option(ENABLE_TESTS      "Set to OFF to disable building test applications" ON)
+option(ENABLE_LIBSVN     "Set to ON to build FlightGear/terrasync with libsvnclient support (default)" ON)
+option(ENABLE_RTI        "Set to ON to build FlightGear with RTI support" OFF)
+option(JPEG_FACTORY      "Set to ON to build FlightGear with JPEG-factory support" OFF)
+
+# additional utilities
+option(ENABLE_FGADMIN    "Set to ON to build the FGADMIN application (default)" ON)
+option(WITH_FGPANEL      "Set to ON to build the fgpanel application (default)" ON)
+option(ENABLE_TESTS      "Set to ON to build test applications (default)" ON)
 
 if(LOGGING)
     # nothing
index 4fd1550215f463439aa529eb578f1c6aaba61d81..5c21f5716e69df9d1d993652f4ab2cf0d15f4042 100644 (file)
@@ -102,19 +102,28 @@ endif()
 
 message(STATUS "SimGear include directory: ${SIMGEAR_INCLUDE_DIR}")
 
+# read the simgear version header file, get the version
+file(READ ${SIMGEAR_INCLUDE_DIR}/simgear/version.h SG_VERSION_FILE)
+
 # make sure the simgear/version.h header exists
-if (NOT EXISTS ${SIMGEAR_INCLUDE_DIR}/simgear/version.h)
+if (NOT SG_VERSION_FILE)
     message(FATAL_ERROR "Found SimGear, but it does not contain a simgear/version.h include! "
-            "SimGear installation is incomplete.")
+            "SimGear installation is incomplete or mismatching.")
+endif()
+
+string(STRIP "${SG_VERSION_FILE}" SIMGEAR_DEFINE)
+string(REPLACE "#define SIMGEAR_VERSION " "" SIMGEAR_VERSION "${SIMGEAR_DEFINE}")
+
+if(NOT SIMGEAR_VERSION)
+    message(FATAL_ERROR "Unable to find SimGear or simgear/version.h does not exist/is invalid. "
+            "Make sure you have installed the SimGear ${SimGear_FIND_VERSION} includes. "
+            "When using non-standard locations, please use 'SIMGEAR_DIR' "
+            "to select the SimGear library location to be used.")
 endif()
 
-# read the simgear version header file, get the version
-file(READ ${SIMGEAR_INCLUDE_DIR}/simgear/version.h sgVersionFile)
-string(STRIP ${sgVersionFile} SIMGEAR_DEFINE)
-string(REPLACE "#define SIMGEAR_VERSION " "" SIMGEAR_VERSION ${SIMGEAR_DEFINE})
 message(STATUS "found SimGear version: ${SIMGEAR_VERSION} (needed ${SimGear_FIND_VERSION})")
 
-if(NOT ${SIMGEAR_VERSION} EQUAL ${SimGear_FIND_VERSION})
+if(NOT "${SIMGEAR_VERSION}" EQUAL "${SimGear_FIND_VERSION}")
     message(FATAL_ERROR "You have installed a mismatching SimGear version ${SIMGEAR_VERSION} "
             "instead of ${SimGear_FIND_VERSION} as required by FlightGear. "
             "When using multiple SimGear installations, please use 'SIMGEAR_DIR' "