Revision: 77552
http://sourceforge.net/p/brlcad/code/77552
Author: starseeker
Date: 2020-10-22 18:23:27 +0000 (Thu, 22 Oct 2020)
Log Message:
-----------
Move environment related setup to a separate file and include it in mainline
CMakeLists.txt. These are grouped here because they potentially impact 3rd
party searching or configuration, and as such must be finalized early in the
process.
Modified Paths:
--------------
brlcad/branches/extbuild/CMakeLists.txt
brlcad/branches/extbuild/misc/CMake/CMakeLists.txt
Added Paths:
-----------
brlcad/branches/extbuild/misc/CMake/BRLCAD_Environment_Setup.cmake
Modified: brlcad/branches/extbuild/CMakeLists.txt
===================================================================
--- brlcad/branches/extbuild/CMakeLists.txt 2020-10-22 18:01:38 UTC (rev
77551)
+++ brlcad/branches/extbuild/CMakeLists.txt 2020-10-22 18:23:27 UTC (rev
77552)
@@ -37,47 +37,7 @@
# See the COPYING file for more details.
#
# ******************************************************************
-#
-# Early versions of this CMakeLists.txt file were based on the VTK
-# CMakeLists.txt file, also licensed under Modified BSD.
-# *******************************************************************
-# *** BRL-CAD's CMakeLists.txt ***
-# *******************************************************************
-#
-# This file defines the toplevel CMake build logic for BRL-CAD.
-# As best as is reasonably possible, proper ordering and
-# separation of tests and settings should be maintained per the
-# recommended standard layout. The tests should be added to the
-# labeled sections below so that they are organized in stages as
-# follows:
-#
-# Stage 0 - information on the package and toplevel CMake settings
-# Stage 1 - define top level options
-# Stage 2 - check programs
-# Stage 3 - check compiler characteristics
-# Stage 4 - check libraries
-# Stage 5 - check headers
-# Stage 6 - check types/structures
-# Stage 7 - check functions
-# Stage 8 - check system services
-# Stage 9 - define the BRL-CAD build targets
-#
-# The output summary should report key information about the final
-# configuration of the build. Comprehensive information is available
-# in the CMake cache file in the build directory, so just hit the
-# high points in the summary.
-#
-# After the main configure process is finished, a summary is printed
-# and various settings and configuration files that require full
-# knowledge of the main configure results are handled.
-#
-# *******************************************************************
-# *** Top Level Settings ***
-# *******************************************************************
-# This file contains the top level CMakeLists.txt logic for the
-# BRL-CAD software package.
-
# Minimum required version of CMake
cmake_minimum_required(VERSION 3.14)
@@ -85,6 +45,28 @@
project(BRLCAD)
#---------------------------------------------------------------------
+# CMake derives much of its functionality from modules, typically
+# stored in one directory - let CMake know where to find them. If we
+# are a subbuild, let the parent's CMAKE_MODULE_PATH supply files before
+# our own, otherwise misc/CMake takes first priority.
+set(BRLCAD_CMAKE_DIR "${BRLCAD_SOURCE_DIR}/misc/CMake")
+list(APPEND CMAKE_MODULE_PATH "${BRLCAD_CMAKE_DIR}")
+
+
+#---------------------------------------------------------------------
+# Setup and checks related to system environment settings. Some of
+# these impact search results needed to set default options, so we
+# do this for both the superbuild and the main build.
+include(BRLCAD_Environment_Setup)
+
+
+#---------------------------------------------------------------------
+# Define various utilities common to both superbuild and the primary
+# build.
+include(BRLCAD_Util)
+
+
+#---------------------------------------------------------------------
# Define the current BRL-CAD version.
# See HACKING for details on how to properly update the version
@@ -122,19 +104,6 @@
set(CMAKE_POSITION_INDEPENDENT_CODE TRUE)
endif(USE_OBJECT_LIBS)
-#---------------------------------------------------------------------
-# CMake derives much of its functionality from modules, typically
-# stored in one directory - let CMake know where to find them. If we
-# are a subbuild, let the parent's CMAKE_MODULE_PATH supply files before
-# our own, otherwise misc/CMake takes first priority.
-set(BRLCAD_CMAKE_DIR "${BRLCAD_SOURCE_DIR}/misc/CMake")
-list(APPEND CMAKE_MODULE_PATH "${BRLCAD_CMAKE_DIR}")
-
-
-#---------------------------------------------------------------------
-# Load general utility routines for BRL-CAD CMake logic
-include(BRLCAD_Util)
-
# Find the executable extension, if there is one
get_filename_component(EXE_EXT "${CMAKE_COMMAND}" EXT)
@@ -177,17 +146,6 @@
endif (DEFINED CMAKE_INSTALL_PREFIX AND NOT DEFINED BRLCAD_INSTALL_PREFIX)
#---------------------------------------------------------------------
-# Allow the BRLCAD_ROOT environment variable to set during build, but be noisy
-# about it unless we're specifically told this is intentional. Having this
-# happen by accident is generally not a good idea.
-find_program(SLEEP_EXEC sleep)
-mark_as_advanced(SLEEP_EXEC)
-if(NOT "$ENV{BRLCAD_ROOT}" STREQUAL "" AND NOT BRLCAD_ROOT_OVERRIDE)
- message(WARNING "\nBRLCAD_ROOT is presently set to
\"$ENV{BRLCAD_ROOT}\"\nBRLCAD_ROOT should typically be used only when needed as
a runtime override, not during compilation. Building with BRLCAD_ROOT set may
produce unexpected behavior during both compilation and subsequent program
execution. It is *highly* recommended that BRLCAD_ROOT be unset and not
used.\n")
- if(SLEEP_EXEC)
- execute_process(COMMAND ${SLEEP_EXEC} 2)
- endif(SLEEP_EXEC)
-endif(NOT "$ENV{BRLCAD_ROOT}" STREQUAL "" AND NOT BRLCAD_ROOT_OVERRIDE)
# If BRLCAD_INSTALL_PREFIX is "/usr", be VERY noisy about it - a make install
in
# this location is dangerous/destructive on some systems.
@@ -547,69 +505,8 @@
include(CheckCSourceCompiles)
include(CheckCXXSourceCompiles)
-#---------------------------------------------------------------------
-# Save the current LC_ALL, LC_MESSAGES, and LANG environment variables
-# and set them to "C" so things like date output are as expected.
-set(_orig_lc_all $ENV{LC_ALL})
-set(_orig_lc_messages $ENV{LC_MESSAGES})
-set(_orig_lang $ENV{LANG})
-if(_orig_lc_all)
- set(ENV{LC_ALL} C)
-endif(_orig_lc_all)
-if(_orig_lc_messages)
- set(ENV{LC_MESSAGES} C)
-endif(_orig_lc_messages)
-if(_orig_lang)
- set(ENV{LANG} C)
-endif(_orig_lang)
#---------------------------------------------------------------------
-# Package creation with CMake depends on the value of umask - if permissions
-# are such that temporary files are created without permissions needed for
-# generated packages, the resulting packages may behave badly when installed.
-# In particular, RPM packages may improperly reset permissions on core
-# directories such as /usr.
-function(check_umask umask_val status_var)
- string(REGEX REPLACE "[^x]" "" umask_x "${umask_val}")
- string(REGEX REPLACE "[^r]" "" umask_r "${umask_val}")
- string(LENGTH "${umask_r}" UMASK_HAVE_R)
- set(${status_var} 0 PARENT_SCOPE)
- if(UMASK_HAVE_R AND "${umask_x}" STREQUAL "xxx")
- set(${status_var} 1 PARENT_SCOPE)
- endif(UMASK_HAVE_R AND "${umask_x}" STREQUAL "xxx")
-endfunction(check_umask)
-
-# Note - umask is not always an executable, so find_program wont' necessarily
-# determine whether the umask check is appropriate. If we don't find an
-# executable, follow up to see if we can use sh to get the info.
-find_program(UMASK_EXEC umask)
-mark_as_advanced(UMASK_EXEC)
-if(NOT UMASK_EXEC)
- # If we don't have a umask cmd, see if sh -c "umask -S" works
- execute_process(COMMAND sh -c "umask -S" OUTPUT_VARIABLE umask_out)
- # Check if we've got something that looks like a umask output
- if("${umask_out}" MATCHES "^u=.*g=.*o=.*")
- set(UMASK_EXEC sh)
- set(UMASK_EXEC_ARGS -c "umask -S")
- endif("${umask_out}" MATCHES "^u=.*g=.*o=.*")
-else(NOT UMASK_EXEC)
- set(UMASK_EXEC_ARGS -S)
-endif(NOT UMASK_EXEC)
-
-if(UMASK_EXEC)
- execute_process(COMMAND ${UMASK_EXEC} ${UMASK_EXEC_ARGS} OUTPUT_VARIABLE
umask_curr)
- string(STRIP "${umask_curr}" umask_curr)
- check_umask("${umask_curr}" UMASK_OK)
- if(NOT UMASK_OK)
- message(" ")
- message(WARNING "umask is set to ${umask_curr} - this setting is not
recommended if one of the goals of this build is to generate packages. Use
'umask 022' for improved package behavior.")
- if(SLEEP_EXEC)
- execute_process(COMMAND ${SLEEP_EXEC} 1)
- endif(SLEEP_EXEC)
- endif(NOT UMASK_OK)
-endif(UMASK_EXEC)
-
-#---------------------------------------------------------------------
# print out the title with a pretty box computed to wrap around
BOX_PRINT("*** Configuring BRL-CAD Release ${BRLCAD_VERSION}, Build
${CONFIG_DATE} ***" "*")
@@ -904,90 +801,6 @@
CONFIG_H_APPEND(BRLCAD "#define NDEBUG 1\n")
endif(NOT "${CMAKE_BUILD_TYPE}" STREQUAL "Debug" AND NOT
CMAKE_CONFIGURATION_TYPES)
-#----------------------------------------------------------------------
-# Decide whether to do a 32 or a 64 bit build.
-
-set(WORD_SIZE_LABEL "Compile as 32BIT or 64BIT?")
-if(NOT BRLCAD_WORD_SIZE)
- set(BRLCAD_WORD_SIZE "AUTO" CACHE STRING WORD_SIZE_LABEL)
-endif(NOT BRLCAD_WORD_SIZE)
-set_property(CACHE BRLCAD_WORD_SIZE PROPERTY STRINGS AUTO 32BIT 64BIT)
-string(TOUPPER "${BRLCAD_WORD_SIZE}" BRLCAD_WORD_SIZE_UPPER)
-set(BRLCAD_WORD_SIZE "${BRLCAD_WORD_SIZE_UPPER}" CACHE STRING WORD_SIZE_LABEL
FORCE)
-if(NOT BRLCAD_WORD_SIZE MATCHES "AUTO" AND NOT BRLCAD_WORD_SIZE MATCHES
"64BIT" AND NOT BRLCAD_WORD_SIZE MATCHES "32BIT")
- message(WARNING "Unknown value ${BRLCAD_WORD_SIZE} supplied for
BRLCAD_WORD_SIZE - defaulting to AUTO")
- message(WARNING "Valid options are AUTO, 32BIT and 64BIT")
- set(BRLCAD_WORD_SIZE "AUTO" CACHE STRING WORD_SIZE_LABEL FORCE)
-endif(NOT BRLCAD_WORD_SIZE MATCHES "AUTO" AND NOT BRLCAD_WORD_SIZE MATCHES
"64BIT" AND NOT BRLCAD_WORD_SIZE MATCHES "32BIT")
-# On Windows, we can't set word size at CMake configure time - the
-# compiler chosen at the beginning dictates the result. Mark as
-# advanced in that situation.
-if(MSVC)
- mark_as_advanced(BRLCAD_WORD_SIZE)
-endif(MSVC)
-
-# calculate the size of a pointer if we haven't already
-CHECK_TYPE_SIZE("void *" CMAKE_SIZEOF_VOID_P)
-
-# still not defined?
-if(NOT CMAKE_SIZEOF_VOID_P)
- message(WARNING "CMAKE_SIZEOF_VOID_P is not defined - assuming 32 bit
platform")
- set(CMAKE_SIZEOF_VOID_P 4)
-endif(NOT CMAKE_SIZEOF_VOID_P)
-
-if(${BRLCAD_WORD_SIZE} MATCHES "AUTO")
- if(${CMAKE_SIZEOF_VOID_P} MATCHES "^8$")
- set(CMAKE_WORD_SIZE "64BIT")
- set(BRLCAD_WORD_SIZE "64BIT (AUTO)" CACHE STRING WORD_SIZE_LABEL FORCE)
- else(${CMAKE_SIZEOF_VOID_P} MATCHES "^8$")
- if(${CMAKE_SIZEOF_VOID_P} MATCHES "^4$")
- set(CMAKE_WORD_SIZE "32BIT")
- set(BRLCAD_WORD_SIZE "32BIT (AUTO)" CACHE STRING WORD_SIZE_LABEL FORCE)
- else(${CMAKE_SIZEOF_VOID_P} MATCHES "^4$")
- if(${CMAKE_SIZEOF_VOID_P} MATCHES "^2$")
- set(CMAKE_WORD_SIZE "16BIT")
- set(BRLCAD_WORD_SIZE "16BIT (AUTO)" CACHE STRING WORD_SIZE_LABEL FORCE)
- else(${CMAKE_SIZEOF_VOID_P} MATCHES "^2$")
- set(CMAKE_WORD_SIZE "8BIT")
- set(BRLCAD_WORD_SIZE "8BIT (AUTO)" CACHE STRING WORD_SIZE_LABEL FORCE)
- endif(${CMAKE_SIZEOF_VOID_P} MATCHES "^2$")
- endif(${CMAKE_SIZEOF_VOID_P} MATCHES "^4$")
- endif(${CMAKE_SIZEOF_VOID_P} MATCHES "^8$")
-else(${BRLCAD_WORD_SIZE} MATCHES "AUTO")
- set(CMAKE_WORD_SIZE "${BRLCAD_WORD_SIZE}")
-endif(${BRLCAD_WORD_SIZE} MATCHES "AUTO")
-
-# Enable/disable 64-bit build settings for MSVC, which is apparently
-# determined at the CMake generator level - need to override other
-# settings if the compiler disagrees with them.
-if(MSVC)
- if(CMAKE_CL_64)
- if(NOT ${CMAKE_WORD_SIZE} MATCHES "64BIT")
- set(CMAKE_WORD_SIZE "64BIT")
- if(NOT "${BRLCAD_WORD_SIZE}" MATCHES "AUTO")
- message(WARNING "Selected MSVC compiler is 64BIT - setting word size to
64BIT. To perform a 32BIT MSVC build, select the 32BIT MSVC CMake generator.")
- set(BRLCAD_WORD_SIZE "64BIT" CACHE STRING WORD_SIZE_LABEL FORCE)
- endif(NOT "${BRLCAD_WORD_SIZE}" MATCHES "AUTO")
- endif(NOT ${CMAKE_WORD_SIZE} MATCHES "64BIT")
- add_definitions("-D_WIN64")
- else(CMAKE_CL_64)
- set(CMAKE_SIZEOF_VOID_P 4)
- if(NOT ${CMAKE_WORD_SIZE} MATCHES "32BIT")
- set(CMAKE_WORD_SIZE "32BIT")
- if(NOT "${BRLCAD_WORD_SIZE}" MATCHES "AUTO")
- message(WARNING "Selected MSVC compiler is 32BIT - setting word size to
32BIT. To perform a 64BIT MSVC build, select the 64BIT MSVC CMake generator.")
- set(BRLCAD_WORD_SIZE "32BIT" CACHE STRING WORD_SIZE_LABEL FORCE)
- endif(NOT "${BRLCAD_WORD_SIZE}" MATCHES "AUTO")
- endif(NOT ${CMAKE_WORD_SIZE} MATCHES "32BIT")
- endif(CMAKE_CL_64)
-endif(MSVC)
-
-if (APPLE)
- if (${CMAKE_WORD_SIZE} MATCHES "32BIT")
- set(CMAKE_OSX_ARCHITECTURES "i386" CACHE STRING "Building for i386" FORCE)
- endif (${CMAKE_WORD_SIZE} MATCHES "32BIT")
-endif (APPLE)
-
CONFIG_H_APPEND(BRLCAD "#define SIZEOF_VOID_P ${CMAKE_SIZEOF_VOID_P}\n")
# OpenBSD doesn't define __WORD_SIZE
@@ -998,31 +811,6 @@
CONFIG_H_APPEND(BRLCAD "#ifndef __WORDSIZE\n# define __WORDSIZE
64\n#endif\n")
endif(${CMAKE_WORD_SIZE} MATCHES "64BIT")
-# Based on what we are doing, we may need to constrain our search paths
-#
-# NOTE: Ideally we would set a matching property for 32 bit paths
-# on systems that default to 64 bit - as of 2.8.8 CMake doesn't yet
-# support FIND_LIBRARY_USE_LIB32_PATHS. There is a bug report on the
-# topic here: http://www.cmake.org/Bug/view.php?id=11260
-#
-if(${CMAKE_WORD_SIZE} MATCHES "32BIT")
- set_property(GLOBAL PROPERTY FIND_LIBRARY_USE_LIB64_PATHS OFF)
-else(${CMAKE_WORD_SIZE} MATCHES "32BIT")
- set_property(GLOBAL PROPERTY FIND_LIBRARY_USE_LIB64_PATHS ON)
-endif(${CMAKE_WORD_SIZE} MATCHES "32BIT")
-
-# One of the problems with 32/64 building is we need to search anew
-# for 64 bit libs after a 32 bit configure, or vice versa.
-if(PREVIOUS_CONFIGURE_TYPE)
- if(NOT ${PREVIOUS_CONFIGURE_TYPE} MATCHES ${CMAKE_WORD_SIZE})
- include(ResetCache)
- RESET_CACHE_file()
- endif(NOT ${PREVIOUS_CONFIGURE_TYPE} MATCHES ${CMAKE_WORD_SIZE})
-endif(PREVIOUS_CONFIGURE_TYPE)
-
-set(PREVIOUS_CONFIGURE_TYPE ${CMAKE_WORD_SIZE} CACHE STRING "Previous
configuration word size" FORCE)
-mark_as_advanced(PREVIOUS_CONFIGURE_TYPE)
-
# Auto-reconfiguration - by default, a CMake generated build system
# will re-run CMake if it detects that build system logic has changed.
# This is normally a good thing, but becomes problematic when using
Added: brlcad/branches/extbuild/misc/CMake/BRLCAD_Environment_Setup.cmake
===================================================================
--- brlcad/branches/extbuild/misc/CMake/BRLCAD_Environment_Setup.cmake
(rev 0)
+++ brlcad/branches/extbuild/misc/CMake/BRLCAD_Environment_Setup.cmake
2020-10-22 18:23:27 UTC (rev 77552)
@@ -0,0 +1,188 @@
+# Setup and checks related to system environment settings
+
+#---------------------------------------------------------------------
+# Save the current LC_ALL, LC_MESSAGES, and LANG environment variables
+# and set them to "C" so things like date output are as expected.
+set(_orig_lc_all $ENV{LC_ALL})
+set(_orig_lc_messages $ENV{LC_MESSAGES})
+set(_orig_lang $ENV{LANG})
+if(_orig_lc_all)
+ set(ENV{LC_ALL} C)
+endif(_orig_lc_all)
+if(_orig_lc_messages)
+ set(ENV{LC_MESSAGES} C)
+endif(_orig_lc_messages)
+if(_orig_lang)
+ set(ENV{LANG} C)
+endif(_orig_lang)
+
+#---------------------------------------------------------------------
+# Package creation with CMake depends on the value of umask - if permissions
+# are such that temporary files are created without permissions needed for
+# generated packages, the resulting packages may behave badly when installed.
+# In particular, RPM packages may improperly reset permissions on core
+# directories such as /usr.
+function(check_umask umask_val status_var)
+ string(REGEX REPLACE "[^x]" "" umask_x "${umask_val}")
+ string(REGEX REPLACE "[^r]" "" umask_r "${umask_val}")
+ string(LENGTH "${umask_r}" UMASK_HAVE_R)
+ set(${status_var} 0 PARENT_SCOPE)
+ if(UMASK_HAVE_R AND "${umask_x}" STREQUAL "xxx")
+ set(${status_var} 1 PARENT_SCOPE)
+ endif(UMASK_HAVE_R AND "${umask_x}" STREQUAL "xxx")
+endfunction(check_umask)
+
+# Note - umask is not always an executable, so find_program wont' necessarily
+# determine whether the umask check is appropriate. If we don't find an
+# executable, follow up to see if we can use sh to get the info.
+find_program(UMASK_EXEC umask)
+mark_as_advanced(UMASK_EXEC)
+if(NOT UMASK_EXEC)
+ # If we don't have a umask cmd, see if sh -c "umask -S" works
+ execute_process(COMMAND sh -c "umask -S" OUTPUT_VARIABLE umask_out)
+ # Check if we've got something that looks like a umask output
+ if("${umask_out}" MATCHES "^u=.*g=.*o=.*")
+ set(UMASK_EXEC sh)
+ set(UMASK_EXEC_ARGS -c "umask -S")
+ endif("${umask_out}" MATCHES "^u=.*g=.*o=.*")
+else(NOT UMASK_EXEC)
+ set(UMASK_EXEC_ARGS -S)
+endif(NOT UMASK_EXEC)
+
+if(UMASK_EXEC)
+ execute_process(COMMAND ${UMASK_EXEC} ${UMASK_EXEC_ARGS} OUTPUT_VARIABLE
umask_curr)
+ string(STRIP "${umask_curr}" umask_curr)
+ check_umask("${umask_curr}" UMASK_OK)
+ if(NOT UMASK_OK)
+ message(" ")
+ message(WARNING "umask is set to ${umask_curr} - this setting is not
recommended if one of the goals of this build is to generate packages. Use
'umask 022' for improved package behavior.")
+ if(SLEEP_EXEC)
+ execute_process(COMMAND ${SLEEP_EXEC} 1)
+ endif(SLEEP_EXEC)
+ endif(NOT UMASK_OK)
+endif(UMASK_EXEC)
+
+#---------------------------------------------------------------------
+# Allow the BRLCAD_ROOT environment variable to set during build, but be noisy
+# about it unless we're specifically told this is intentional. Having this
+# happen by accident is generally not a good idea.
+find_program(SLEEP_EXEC sleep)
+mark_as_advanced(SLEEP_EXEC)
+if(NOT "$ENV{BRLCAD_ROOT}" STREQUAL "" AND NOT BRLCAD_ROOT_OVERRIDE)
+ message(WARNING "\nBRLCAD_ROOT is presently set to
\"$ENV{BRLCAD_ROOT}\"\nBRLCAD_ROOT should typically be used only when needed as
a runtime override, not during compilation. Building with BRLCAD_ROOT set may
produce unexpected behavior during both compilation and subsequent program
execution. It is *highly* recommended that BRLCAD_ROOT be unset and not
used.\n")
+ if(SLEEP_EXEC)
+ execute_process(COMMAND ${SLEEP_EXEC} 2)
+ endif(SLEEP_EXEC)
+endif(NOT "$ENV{BRLCAD_ROOT}" STREQUAL "" AND NOT BRLCAD_ROOT_OVERRIDE)
+
+#---------------------------------------------------------------------
+# Characterize the system as 32 or 64 bit - this has an impact on many
+# of the subsequent operations, including find_package results, so it
+# must be done up front.
+set(WORD_SIZE_LABEL "Compile as 32BIT or 64BIT?")
+if(NOT BRLCAD_WORD_SIZE)
+ set(BRLCAD_WORD_SIZE "AUTO" CACHE STRING WORD_SIZE_LABEL)
+endif(NOT BRLCAD_WORD_SIZE)
+set_property(CACHE BRLCAD_WORD_SIZE PROPERTY STRINGS AUTO 32BIT 64BIT)
+string(TOUPPER "${BRLCAD_WORD_SIZE}" BRLCAD_WORD_SIZE_UPPER)
+set(BRLCAD_WORD_SIZE "${BRLCAD_WORD_SIZE_UPPER}" CACHE STRING WORD_SIZE_LABEL
FORCE)
+if(NOT BRLCAD_WORD_SIZE MATCHES "AUTO" AND NOT BRLCAD_WORD_SIZE MATCHES
"64BIT" AND NOT BRLCAD_WORD_SIZE MATCHES "32BIT")
+ message(WARNING "Unknown value ${BRLCAD_WORD_SIZE} supplied for
BRLCAD_WORD_SIZE - defaulting to AUTO")
+ message(WARNING "Valid options are AUTO, 32BIT and 64BIT")
+ set(BRLCAD_WORD_SIZE "AUTO" CACHE STRING WORD_SIZE_LABEL FORCE)
+endif(NOT BRLCAD_WORD_SIZE MATCHES "AUTO" AND NOT BRLCAD_WORD_SIZE MATCHES
"64BIT" AND NOT BRLCAD_WORD_SIZE MATCHES "32BIT")
+# On Windows, we can't set word size at CMake configure time - the
+# compiler chosen at the beginning dictates the result. Mark as
+# advanced in that situation.
+if(MSVC)
+ mark_as_advanced(BRLCAD_WORD_SIZE)
+endif(MSVC)
+
+# calculate the size of a pointer if we haven't already
+include(CheckTypeSize)
+check_type_size("void *" CMAKE_SIZEOF_VOID_P)
+
+# still not defined?
+if(NOT CMAKE_SIZEOF_VOID_P)
+ message(WARNING "CMAKE_SIZEOF_VOID_P is not defined - assuming 32 bit
platform")
+ set(CMAKE_SIZEOF_VOID_P 4)
+endif(NOT CMAKE_SIZEOF_VOID_P)
+
+if(${BRLCAD_WORD_SIZE} MATCHES "AUTO")
+ if(${CMAKE_SIZEOF_VOID_P} MATCHES "^8$")
+ set(CMAKE_WORD_SIZE "64BIT")
+ set(BRLCAD_WORD_SIZE "64BIT (AUTO)" CACHE STRING WORD_SIZE_LABEL FORCE)
+ else(${CMAKE_SIZEOF_VOID_P} MATCHES "^8$")
+ if(${CMAKE_SIZEOF_VOID_P} MATCHES "^4$")
+ set(CMAKE_WORD_SIZE "32BIT")
+ set(BRLCAD_WORD_SIZE "32BIT (AUTO)" CACHE STRING WORD_SIZE_LABEL FORCE)
+ else(${CMAKE_SIZEOF_VOID_P} MATCHES "^4$")
+ if(${CMAKE_SIZEOF_VOID_P} MATCHES "^2$")
+ set(CMAKE_WORD_SIZE "16BIT")
+ set(BRLCAD_WORD_SIZE "16BIT (AUTO)" CACHE STRING WORD_SIZE_LABEL FORCE)
+ else(${CMAKE_SIZEOF_VOID_P} MATCHES "^2$")
+ set(CMAKE_WORD_SIZE "8BIT")
+ set(BRLCAD_WORD_SIZE "8BIT (AUTO)" CACHE STRING WORD_SIZE_LABEL FORCE)
+ endif(${CMAKE_SIZEOF_VOID_P} MATCHES "^2$")
+ endif(${CMAKE_SIZEOF_VOID_P} MATCHES "^4$")
+ endif(${CMAKE_SIZEOF_VOID_P} MATCHES "^8$")
+else(${BRLCAD_WORD_SIZE} MATCHES "AUTO")
+ set(CMAKE_WORD_SIZE "${BRLCAD_WORD_SIZE}")
+endif(${BRLCAD_WORD_SIZE} MATCHES "AUTO")
+
+# Enable/disable 64-bit build settings for MSVC, which is apparently
+# determined at the CMake generator level - need to override other
+# settings if the compiler disagrees with them.
+if(MSVC)
+ if(CMAKE_CL_64)
+ if(NOT ${CMAKE_WORD_SIZE} MATCHES "64BIT")
+ set(CMAKE_WORD_SIZE "64BIT")
+ if(NOT "${BRLCAD_WORD_SIZE}" MATCHES "AUTO")
+ message(WARNING "Selected MSVC compiler is 64BIT - setting word size
to 64BIT. To perform a 32BIT MSVC build, select the 32BIT MSVC CMake
generator.")
+ set(BRLCAD_WORD_SIZE "64BIT" CACHE STRING WORD_SIZE_LABEL FORCE)
+ endif(NOT "${BRLCAD_WORD_SIZE}" MATCHES "AUTO")
+ endif(NOT ${CMAKE_WORD_SIZE} MATCHES "64BIT")
+ add_definitions("-D_WIN64")
+ else(CMAKE_CL_64)
+ set(CMAKE_SIZEOF_VOID_P 4)
+ if(NOT ${CMAKE_WORD_SIZE} MATCHES "32BIT")
+ set(CMAKE_WORD_SIZE "32BIT")
+ if(NOT "${BRLCAD_WORD_SIZE}" MATCHES "AUTO")
+ message(WARNING "Selected MSVC compiler is 32BIT - setting word size
to 32BIT. To perform a 64BIT MSVC build, select the 64BIT MSVC CMake
generator.")
+ set(BRLCAD_WORD_SIZE "32BIT" CACHE STRING WORD_SIZE_LABEL FORCE)
+ endif(NOT "${BRLCAD_WORD_SIZE}" MATCHES "AUTO")
+ endif(NOT ${CMAKE_WORD_SIZE} MATCHES "32BIT")
+ endif(CMAKE_CL_64)
+endif(MSVC)
+
+if (APPLE)
+ if (${CMAKE_WORD_SIZE} MATCHES "32BIT")
+ set(CMAKE_OSX_ARCHITECTURES "i386" CACHE STRING "Building for i386" FORCE)
+ endif (${CMAKE_WORD_SIZE} MATCHES "32BIT")
+endif (APPLE)
+
+# Based on what we are doing, we may need to constrain our search paths
+#
+# NOTE: Ideally we would set a matching property for 32 bit paths
+# on systems that default to 64 bit - as of 2.8.8 CMake doesn't yet
+# support FIND_LIBRARY_USE_LIB32_PATHS. There is a bug report on the
+# topic here: http://www.cmake.org/Bug/view.php?id=11260
+#
+if(${CMAKE_WORD_SIZE} MATCHES "32BIT")
+ set_property(GLOBAL PROPERTY FIND_LIBRARY_USE_LIB64_PATHS OFF)
+else(${CMAKE_WORD_SIZE} MATCHES "32BIT")
+ set_property(GLOBAL PROPERTY FIND_LIBRARY_USE_LIB64_PATHS ON)
+endif(${CMAKE_WORD_SIZE} MATCHES "32BIT")
+
+# One of the problems with 32/64 building is we need to search anew
+# for 64 bit libs after a 32 bit configure, or vice versa.
+if(PREVIOUS_CONFIGURE_TYPE)
+ if(NOT ${PREVIOUS_CONFIGURE_TYPE} MATCHES ${CMAKE_WORD_SIZE})
+ include(ResetCache)
+ RESET_CACHE_file()
+ endif(NOT ${PREVIOUS_CONFIGURE_TYPE} MATCHES ${CMAKE_WORD_SIZE})
+endif(PREVIOUS_CONFIGURE_TYPE)
+
+set(PREVIOUS_CONFIGURE_TYPE ${CMAKE_WORD_SIZE} CACHE STRING "Previous
configuration word size" FORCE)
+mark_as_advanced(PREVIOUS_CONFIGURE_TYPE)
+
Property changes on:
brlcad/branches/extbuild/misc/CMake/BRLCAD_Environment_Setup.cmake
___________________________________________________________________
Added: svn:eol-style
## -0,0 +1 ##
+native
\ No newline at end of property
Added: svn:mime-type
## -0,0 +1 ##
+text/plain
\ No newline at end of property
Modified: brlcad/branches/extbuild/misc/CMake/CMakeLists.txt
===================================================================
--- brlcad/branches/extbuild/misc/CMake/CMakeLists.txt 2020-10-22 18:01:38 UTC
(rev 77551)
+++ brlcad/branches/extbuild/misc/CMake/CMakeLists.txt 2020-10-22 18:23:27 UTC
(rev 77552)
@@ -1,6 +1,7 @@
set(cmake_ignore_files
BRLCAD_CPackOptions.cmake.in
BRLCAD_CheckFunctions.cmake
+ BRLCAD_Environment_Setup.cmake
BRLCAD_Options.cmake
BRLCAD_Regress_Util.cmake
BRLCAD_Summary.cmake
This was sent by the SourceForge.net collaborative development platform, the
world's largest Open Source development site.
_______________________________________________
BRL-CAD Source Commits mailing list
[email protected]
https://lists.sourceforge.net/lists/listinfo/brlcad-commits