diff --git a/CMakeLists.txt b/CMakeLists.txt index 2cd2f8d..251dc7a 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -32,6 +32,11 @@ if(NOT CMAKE_BUILD_TYPE) endif(NOT CMAKE_BUILD_TYPE) message(STATUS "Build type: ${CMAKE_BUILD_TYPE}") +# Turn on GPOS_DEBUG define for DEBUG builds. +if (CMAKE_BUILD_TYPE MATCHES "Debug") + set(GPOS_DEBUG 1) +endif() + # Override CMAKE_SYSTEM_PROCESSOR if it has been explicitly set in a toolchain file. if (FORCED_CMAKE_SYSTEM_PROCESSOR) set(CMAKE_SYSTEM_PROCESSOR ${FORCED_CMAKE_SYSTEM_PROCESSOR}) @@ -102,19 +107,6 @@ if (COMPILER_HAS_FNO_OMIT_FRAME_POINTER) SET(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -fno-omit-frame-pointer") endif() -# Turn on GPOS_DEBUG define for DEBUG builds. -cmake_policy(SET CMP0043 NEW) -set_property( - DIRECTORY - APPEND PROPERTY COMPILE_DEFINITIONS $<$:GPOS_DEBUG>) - -# Turn on platform-specific defines. -set_property( - DIRECTORY - APPEND PROPERTY COMPILE_DEFINITIONS - GPOS_${CMAKE_SYSTEM_NAME} - GPOS_${CMAKE_SYSTEM_PROCESSOR}) - # Autodetect bit-width if not already set by toolchain file. if (NOT GPOS_ARCH_BITS) # Autodetect bit-width. @@ -133,11 +125,6 @@ if (NOT GPOS_ARCH_BITS) endif() endif() -set_property( - DIRECTORY - APPEND PROPERTY COMPILE_DEFINITIONS - GPOS_${GPOS_ARCH_BITS}BIT) - # Need pthreads. find_package(Threads REQUIRED) if (NOT CMAKE_USE_PTHREADS_INIT) @@ -158,9 +145,14 @@ endif() include_directories(libgpos/include) -# Generate version-number header. +# Generate version-number and config headers. configure_file(version.h.in ${PROJECT_BINARY_DIR}/libgpos/include/gpos/version.h) +configure_file(config.h.in + ${PROJECT_BINARY_DIR}/libgpos/include/gpos/config.h) + +# Make the generated header files available at compilation of libgpos itself. +include_directories(${PROJECT_BINARY_DIR}/libgpos/include/) # Compile .cpp source files under libgpos/src into monolithic gpos library. add_library(gpos @@ -432,12 +424,16 @@ if (VERBOSE_INSTALL_PATH) install(DIRECTORY libgpos/include/gpos DESTINATION "${installpath}/include") install(FILES "${PROJECT_BINARY_DIR}/libgpos/include/gpos/version.h" DESTINATION "${installpath}/include/gpos") + install(FILES "${PROJECT_BINARY_DIR}/libgpos/include/gpos/config.h" + DESTINATION "${installpath}/include/gpos") else() get_filename_component(full_install_name_dir "${CMAKE_INSTALL_PREFIX}/lib" ABSOLUTE) install(TARGETS gpos DESTINATION lib) install(DIRECTORY libgpos/include/gpos DESTINATION include) install(FILES "${PROJECT_BINARY_DIR}/libgpos/include/gpos/version.h" DESTINATION include/gpos) + install(FILES "${PROJECT_BINARY_DIR}/libgpos/include/gpos/config.h" + DESTINATION include/gpos) endif() # Mac OS X handles searching for dynamic libraries differently from other diff --git a/config.h.in b/config.h.in new file mode 100644 index 0000000..b15a9b9 --- /dev/null +++ b/config.h.in @@ -0,0 +1,26 @@ +//--------------------------------------------------------------------------- +// Greenplum Database +// Copyright (C) 2016 Greenplum, Inc. +// +// @filename: +// config.h +// +// @doc: +// Various compile-time options that affect binary +// compatibility. +// +//--------------------------------------------------------------------------- +#ifndef GPOS_config_H +#define GPOS_config_H + +#cmakedefine GPOS_DEBUG 1 + +// Thes comes from CMAKE_SYSTEM_NAME and CMAKE_SYSTEM_PROCESSOR +#define GPOS_${CMAKE_SYSTEM_NAME} 1 +#define GPOS_${CMAKE_SYSTEM_PROCESSOR} 1 + +// This comes from GPOS_ARCH_BITS (based on CMAKE_SIZEOF_VOID_P) +#define GPOS_${GPOS_ARCH_BITS}BIT 1 + +#endif // GPOS_config_H +// EOF diff --git a/libgpos/include/gpos/_api.h b/libgpos/include/gpos/_api.h index 2da7c2d..c83f867 100644 --- a/libgpos/include/gpos/_api.h +++ b/libgpos/include/gpos/_api.h @@ -17,6 +17,8 @@ #ifndef GPOS_api_H #define GPOS_api_H +#include "gpos/config.h" + #ifdef __cplusplus extern "C" { diff --git a/libgpos/include/gpos/assert.h b/libgpos/include/gpos/assert.h index 16bd5be..00e2d31 100644 --- a/libgpos/include/gpos/assert.h +++ b/libgpos/include/gpos/assert.h @@ -22,6 +22,7 @@ #ifndef GPOS_assert_H #define GPOS_assert_H +#include "gpos/config.h" // retail assert; available in all builds #define GPOS_RTL_ASSERT(x) ((x) ? ((void)0) : \