Commit 9ecc4cab authored by Andreas Schuh's avatar Andreas Schuh

Enable packaging of library using CPack.

parent ddc53574
cmake_minimum_required(VERSION 2.8.4 FATAL_ERROR) cmake_minimum_required (VERSION 2.8.4 FATAL_ERROR)
if (WIN32 AND NOT CYGWIN)
set (OS_WINDOWS 1)
else ()
set (OS_WINDOWS 0)
endif ()
# ---------------------------------------------------------------------------- # ----------------------------------------------------------------------------
# includes # includes
set (CMAKE_MODULE_PATH "${CMAKE_CURRENT_SOURCE_DIR}/cmake") set (CMAKE_MODULE_PATH "${CMAKE_CURRENT_SOURCE_DIR}/cmake")
include (utils) include (utils)
# ---------------------------------------------------------------------------- # ----------------------------------------------------------------------------
# package information # package information
set (PROJECT_NAME "gflags") set (PACKAGE_NAME "gflags")
set (PACKAGE_NAME "${PROJECT_NAME}") set (PACKAGE_VERSION "2.1")
set (PACKAGE_VERSION "2.1.0") set (PACKAGE_STRING "${PACKAGE_NAME} ${PACKAGE_VERSION}")
set (PACKAGE_STRING "${PROJECT_NAME} ${PACKAGE_VERSION}") set (PACKAGE_TARNAME "${PACKAGE_NAME}-${PACKAGE_VERSION}")
set (PACKAGE_TARNAME "${PROJECT_NAME}-${PACKAGE_VERSION}")
set (PACKAGE_BUGREPORT "https://code.google.com/p/gflags/issues/") set (PACKAGE_BUGREPORT "https://code.google.com/p/gflags/issues/")
project (${PROJECT_NAME} CXX) project (${PACKAGE_NAME} CXX)
version_numbers ( version_numbers (
${PACKAGE_VERSION} ${PACKAGE_VERSION}
...@@ -31,42 +23,39 @@ version_numbers ( ...@@ -31,42 +23,39 @@ version_numbers (
) )
# ---------------------------------------------------------------------------- # ----------------------------------------------------------------------------
# configure options # options
option (BUILD_SHARED_LIBS "Request build of shared libraries." OFF) set (GFLAGS_NAMESPACE "${PACKAGE_NAME}" CACHE STRING "C++ namespace identifier of gflags library.")
option (BUILD_SHARED_LIBS "Request build of shared libraries." OFF)
option (BUILD_STATIC_LIBS "Request build of static libraries (default if BUILD_SHARED_LIBS is OFF)." OFF)
option (BUILD_gflags_LIB "Request build of the multi-threaded gflags library." ON)
option (BUILD_gflags_nothreads_LIB "Request build of the single-threaded gflags library." ON)
option (BUILD_PACKAGING "Enable build of distribution packages using CPack." OFF)
option (BUILD_TESTING "Enable build of the unit tests and their execution using CTest." OFF)
option (BUILD_NC_TESTS "Request addition of negative compilation tests." OFF)
option (INSTALL_HEADERS "Request packaging of headers and other development files." ON)
if (OS_WINDOWS AND BUILD_SHARED_LIBS) mark_as_advanced (CLEAR CMAKE_INSTALL_PREFIX)
set (GFLAGS_IS_A_DLL 1) mark_as_advanced (CMAKE_CONFIGURATION_TYPES
else () GFLAGS_NAMESPACE
set (GFLAGS_IS_A_DLL 0) BUILD_STATIC_LIBS
BUILD_NC_TESTS
INSTALL_HEADERS)
if (APPLE)
mark_as_advanced(CMAKE_OSX_ARCHITECTURES
CMAKE_OSX_DEPLOYMENT_TARGET
CMAKE_OSX_SYSROOT)
endif () endif ()
option (BUILD_gflags_LIB "Request build of the multi-threaded gflags library." ON) if (NOT BUILD_SHARED_LIBS AND NOT BUILD_STATIC_LIBS)
option (BUILD_gflags_nothreads_LIB "Request build of the single-threaded gflags library." ON) set (BUILD_STATIC_LIBS ON)
endif ()
if (NOT BUILD_gflags_LIB AND NOT BUILD_gflags_nothreads_LIB) if (NOT BUILD_gflags_LIB AND NOT BUILD_gflags_nothreads_LIB)
message (FATAL_ERROR "At least one of BUILD_gflags_LIB and BUILD_gflags_nothreads_LIB must be ON.") message (FATAL_ERROR "At least one of BUILD_gflags_LIB and BUILD_gflags_nothreads_LIB must be ON.")
endif () endif ()
option (BUILD_NEGATIVE_COMPILATION_TESTS "Request addition of negative compilation tests." OFF) if (NOT CMAKE_BUILD_TYPE AND NOT CMAKE_CXX_FLAGS)
mark_as_advanced (BUILD_NEGATIVE_COMPILATION_TESTS) set_property (CACHE CMAKE_BUILD_TYPE PROPERTY VALUE Release)
set (GFLAGS_NAMESPACE "gflags" CACHE STRING "C++ namespace identifier of gflags library.")
mark_as_advanced (GFLAGS_NAMESPACE)
mark_as_advanced (CLEAR CMAKE_INSTALL_PREFIX)
mark_as_advanced (CMAKE_CONFIGURATION_TYPES)
if (NOT CMAKE_BUILD_TYPE AND NOT CMAKE_CXX_FLAGS AND NOT CMAKE_C_FLAGS)
set (
CMAKE_BUILD_TYPE "Release"
CACHE STRING "Choose the type of build, options are: None (CMAKE_C_FLAGS and CMAKE_CXX_FLAGS used) Debug Release RelWithDebInfo MinSizeRel."
FORCE
)
endif ()
if (APPLE)
mark_as_advanced(CMAKE_OSX_ARCHITECTURES
CMAKE_OSX_DEPLOYMENT_TARGET
CMAKE_OSX_SYSROOT)
endif () endif ()
# ---------------------------------------------------------------------------- # ----------------------------------------------------------------------------
...@@ -75,6 +64,12 @@ include (CheckTypeSize) ...@@ -75,6 +64,12 @@ include (CheckTypeSize)
include (CheckIncludeFileCXX) include (CheckIncludeFileCXX)
include (CheckCXXSymbolExists) include (CheckCXXSymbolExists)
if (WIN32 AND NOT CYGWIN)
set (OS_WINDOWS 1)
else ()
set (OS_WINDOWS 0)
endif ()
if (MSVC) if (MSVC)
set (HAVE_SYS_TYPES_H 1) set (HAVE_SYS_TYPES_H 1)
set (HAVE_STDINT_H 1) set (HAVE_STDINT_H 1)
...@@ -179,6 +174,8 @@ set (PUBLIC_HDRS ...@@ -179,6 +174,8 @@ set (PUBLIC_HDRS
set (PRIVATE_HDRS set (PRIVATE_HDRS
"config.h" "config.h"
"util.h"
"mutex.h"
) )
set (GFLAGS_SRCS set (GFLAGS_SRCS
...@@ -204,6 +201,10 @@ configure_headers (PUBLIC_HDRS ${PUBLIC_HDRS}) ...@@ -204,6 +201,10 @@ configure_headers (PUBLIC_HDRS ${PUBLIC_HDRS})
configure_sources (PRIVATE_HDRS ${PRIVATE_HDRS}) configure_sources (PRIVATE_HDRS ${PRIVATE_HDRS})
configure_sources (GFLAGS_SRCS ${GFLAGS_SRCS}) configure_sources (GFLAGS_SRCS ${GFLAGS_SRCS})
include_directories ("${PROJECT_SOURCE_DIR}/src")
include_directories ("${PROJECT_BINARY_DIR}/include")
include_directories ("${PROJECT_BINARY_DIR}/include/${GFLAGS_NAMESPACE}")
# ---------------------------------------------------------------------------- # ----------------------------------------------------------------------------
# output directories # output directories
set (CMAKE_RUNTIME_OUTPUT_DIRECTORY "bin") set (CMAKE_RUNTIME_OUTPUT_DIRECTORY "bin")
...@@ -211,27 +212,43 @@ set (CMAKE_LIBRARY_OUTPUT_DIRECTORY "lib") ...@@ -211,27 +212,43 @@ set (CMAKE_LIBRARY_OUTPUT_DIRECTORY "lib")
set (CMAKE_ARCHIVE_OUTPUT_DIRECTORY "lib") set (CMAKE_ARCHIVE_OUTPUT_DIRECTORY "lib")
# ---------------------------------------------------------------------------- # ----------------------------------------------------------------------------
# add library target # add library targets
include_directories ("${PROJECT_SOURCE_DIR}/src") set (TARGETS)
include_directories ("${PROJECT_BINARY_DIR}/include") # static vs. shared
include_directories ("${PROJECT_BINARY_DIR}/include/${GFLAGS_NAMESPACE}") foreach (TYPE IN ITEMS STATIC SHARED)
if (BUILD_${TYPE}_LIBS)
set (LIB_TARGETS) # whether or not targets are a DLL
if (BUILD_gflags_LIB) if (OS_WINDOWS AND "^${TYPE}$" STREQUAL "^SHARED$")
add_library (gflags ${GFLAGS_SRCS} ${PRIVATE_HDRS} ${PUBLIC_HDRS}) set (GFLAGS_IS_A_DLL 1)
if (HAVE_SHLWAPI_H) else ()
target_link_libraries (gflags shlwapi.lib) set (GFLAGS_IS_A_DLL 0)
endif () endif ()
list (APPEND LIB_TARGETS gflags) string (TOLOWER "${TYPE}" type)
endif () # multi-threaded vs. single-threaded
if (BUILD_gflags_nothreads_LIB) foreach (opts IN ITEMS "" _nothreads)
add_library (gflags_nothreads ${GFLAGS_SRCS} ${PRIVATE_HDRS} ${PUBLIC_HDRS}) if (BUILD_gflags${opts}_LIB)
set_target_properties (gflags_nothreads PROPERTIES COMPILE_DEFINITIONS NO_THREADS) add_library (gflags${opts}-${type} ${TYPE} ${GFLAGS_SRCS} ${PRIVATE_HDRS} ${PUBLIC_HDRS})
if (HAVE_SHLWAPI_H) if (opts MATCHES "nothreads")
target_link_libraries (gflags_nothreads shlwapi.lib) set (defines "GFLAGS_IS_A_DLL=${GFLAGS_IS_A_DLL};NOTHREADS")
else ()
set (defines "GFLAGS_IS_A_DLL=${GFLAGS_IS_A_DLL}")
endif ()
set_target_properties (
gflags${opts}-${type} PROPERTIES COMPILE_DEFINITIONS "${defines}"
OUTPUT_NAME "gflags${opts}"
)
if (HAVE_SHLWAPI_H)
target_link_libraries (gflags${opts}-${type} shlwapi.lib)
endif ()
if (NOT TARGET gflags${opts})
add_custom_target (gflags${opts})
endif ()
add_dependencies (gflags${opts} gflags${opts}-${type})
list (APPEND TARGETS gflags${opts}-${type})
endif ()
endforeach ()
endif () endif ()
list (APPEND LIB_TARGETS gflags_nothreads) endforeach ()
endif ()
# ---------------------------------------------------------------------------- # ----------------------------------------------------------------------------
# installation # installation
...@@ -247,41 +264,134 @@ else () ...@@ -247,41 +264,134 @@ else ()
set (CONFIG_INSTALL_DIR lib/cmake/${PACKAGE_NAME}) set (CONFIG_INSTALL_DIR lib/cmake/${PACKAGE_NAME})
endif () endif ()
install (TARGETS ${LIB_TARGETS} DESTINATION ${LIBRARY_INSTALL_DIR} EXPORT gflags-lib)
install (FILES ${PUBLIC_HDRS} DESTINATION ${INCLUDE_INSTALL_DIR}/${GFLAGS_NAMESPACE})
file (RELATIVE_PATH INSTALL_PREFIX_REL2CONFIG_DIR "${CMAKE_INSTALL_PREFIX}/${CONFIG_INSTALL_DIR}" "${CMAKE_INSTALL_PREFIX}") file (RELATIVE_PATH INSTALL_PREFIX_REL2CONFIG_DIR "${CMAKE_INSTALL_PREFIX}/${CONFIG_INSTALL_DIR}" "${CMAKE_INSTALL_PREFIX}")
configure_file (cmake/config.cmake.in "${PROJECT_BINARY_DIR}/${PACKAGE_NAME}-config-install.cmake" @ONLY) configure_file (cmake/config.cmake.in "${PROJECT_BINARY_DIR}/${PACKAGE_NAME}-config-install.cmake" @ONLY)
configure_file (cmake/version.cmake.in "${PROJECT_BINARY_DIR}/${PACKAGE_NAME}-config-version.cmake" @ONLY) configure_file (cmake/version.cmake.in "${PROJECT_BINARY_DIR}/${PACKAGE_NAME}-config-version.cmake" @ONLY)
install ( install (TARGETS ${TARGETS} DESTINATION ${LIBRARY_INSTALL_DIR} EXPORT gflags-lib)
FILES "${PROJECT_BINARY_DIR}/${PACKAGE_NAME}-config-install.cmake" if (INSTALL_HEADERS)
RENAME ${PACKAGE_NAME}-config.cmake install (FILES ${PUBLIC_HDRS} DESTINATION ${INCLUDE_INSTALL_DIR}/${GFLAGS_NAMESPACE})
DESTINATION ${CONFIG_INSTALL_DIR} install (
) FILES "${PROJECT_BINARY_DIR}/${PACKAGE_NAME}-config-install.cmake"
RENAME ${PACKAGE_NAME}-config.cmake
install ( DESTINATION ${CONFIG_INSTALL_DIR}
FILES "${PROJECT_BINARY_DIR}/${PACKAGE_NAME}-config-version.cmake" )
DESTINATION ${CONFIG_INSTALL_DIR} install (
) FILES "${PROJECT_BINARY_DIR}/${PACKAGE_NAME}-config-version.cmake"
DESTINATION ${CONFIG_INSTALL_DIR}
install (EXPORT gflags-lib DESTINATION ${CONFIG_INSTALL_DIR} FILE ${PACKAGE_NAME}-export.cmake) )
install (EXPORT gflags-lib DESTINATION ${CONFIG_INSTALL_DIR} FILE ${PACKAGE_NAME}-export.cmake)
if (UNIX) if (UNIX)
install (PROGRAMS src/gflags_completions.sh DESTINATION ${RUNTIME_INSTALL_DIR}) install (PROGRAMS src/gflags_completions.sh DESTINATION ${RUNTIME_INSTALL_DIR})
endif ()
endif () endif ()
# ---------------------------------------------------------------------------- # ----------------------------------------------------------------------------
# support direct use of build tree # support direct use of build tree
set (INSTALL_PREFIX_REL2CONFIG_DIR .) set (INSTALL_PREFIX_REL2CONFIG_DIR .)
export (TARGETS ${LIB_TARGETS} FILE "${PROJECT_BINARY_DIR}/${PACKAGE_NAME}-export.cmake") export (TARGETS ${TARGETS} FILE "${PROJECT_BINARY_DIR}/${PACKAGE_NAME}-export.cmake")
export (PACKAGE gflags) export (PACKAGE gflags)
configure_file (cmake/config.cmake.in "${PROJECT_BINARY_DIR}/${PACKAGE_NAME}-config.cmake" @ONLY) configure_file (cmake/config.cmake.in "${PROJECT_BINARY_DIR}/${PACKAGE_NAME}-config.cmake" @ONLY)
# ---------------------------------------------------------------------------- # ----------------------------------------------------------------------------
# testing - MUST follow the generation of the build tree config file # testing - MUST follow the generation of the build tree config file
include (CTest)
if (BUILD_TESTING) if (BUILD_TESTING)
include (CTest)
enable_testing () enable_testing ()
add_subdirectory (test) add_subdirectory (test)
endif () endif ()
# ----------------------------------------------------------------------------
# packaging
if (BUILD_PACKAGING)
if (NOT BUILD_SHARED_LIBS AND NOT INSTALL_HEADERS)
message (WARNING "Package will contain static libraries without headers!"
"\nRecommended options for generation of runtime package:"
"\n BUILD_SHARED_LIBS=ON"
"\n BUILD_STATIC_LIBS=OFF"
"\n INSTALL_HEADERS=OFF"
"\nRecommended options for generation of development package:"
"\n BUILD_SHARED_LIBS=ON"
"\n BUILD_STATIC_LIBS=ON"
"\n INSTALL_HEADERS=ON")
endif ()
# default package generators
if (APPLE)
set (PACKAGE_GENERATOR "PackageMaker")
set (PACKAGE_SOURCE_GENERATOR "TGZ;ZIP")
elseif (UNIX)
set (PACKAGE_GENERATOR "DEB;RPM")
set (PACKAGE_SOURCE_GENERATOR "TGZ;ZIP")
else ()
set (PACKAGE_GENERATOR "ZIP")
set (PACKAGE_SOURCE_GENERATOR "ZIP")
endif ()
# used package generators
set (CPACK_GENERATOR "${PACKAGE_GENERATOR}" CACHE STRING "List of binary package generators (CPack).")
set (CPACK_SOURCE_GENERATOR "${PACKAGE_SOURCE_GENERATOR}" CACHE STRING "List of source package generators (CPack).")
mark_as_advanced (CPACK_GENERATOR CPACK_SOURCE_GENERATOR)
# common package information
set (CPACK_PACKAGE_VENDOR "Open Source by Andreas Schuh")
set (CPACK_PACKAGE_CONTACT "google-gflags@googlegroups.com")
set (CPACK_PACKAGE_NAME "${PACKAGE_NAME}")
set (CPACK_PACKAGE_VERSION "${PACKAGE_VERSION}")
set (CPACK_PACKAGE_VERSION_MAJOR "${PACKAGE_VERSION_MAJOR}")
set (CPACK_PACKAGE_VERSION_MINOR "${PACKAGE_VERSION_MINOR}")
set (CPACK_PACKAGE_VERSION_PATCH "${PACKAGE_VERSION_PATCH}")
set (CPACK_PACKAGE_DESCRIPTION_SUMMARY "A commandline flags library that allows for distributed flags.")
set (CPACK_RESOURCE_FILE_WELCOME "${CMAKE_CURRENT_LIST_DIR}/README.txt")
set (CPACK_RESOURCE_FILE_LICENSE "${CMAKE_CURRENT_LIST_DIR}/COPYING.txt")
set (CPACK_PACKAGE_DESCRIPTION_FILE "${CMAKE_CURRENT_LIST_DIR}/INSTALL.txt")
set (CPACK_INSTALL_PREFIX "${CMAKE_INSTALL_PREFIX}")
set (CPACK_OUTPUT_FILE_PREFIX packages)
set (CPACK_PACKAGE_RELOCATABLE TRUE)
set (CPACK_MONOLITHIC_INSTALL TRUE)
if (INSTALL_HEADERS)
set (CPACK_RESOURCE_FILE_README "${CMAKE_CURRENT_LIST_DIR}/doc/gflags.html")
else ()
set (CPACK_RESOURCE_FILE_README "${CMAKE_CURRENT_LIST_DIR}/cmake/README_runtime.txt")
endif ()
# system name used for binary package file name
if (WINDOWS)
if (CMAKE_CL_64)
set (CPACK_SYSTEM_NAME "win64")
else ()
set (CPACK_SYSTEM_NAME "win32")
endif ()
else ()
string (TOLOWER "${CMAKE_SYSTEM_NAME}" CPACK_SYSTEM_NAME)
endif ()
# source package settings
set (CPACK_SOURCE_TOPLEVEL_TAG "source")
set (CPACK_SOURCE_PACKAGE_FILE_NAME "${CPACK_PACKAGE_NAME}-${CPACK_PACKAGE_VERSION}")
set (CPACK_SOURCE_IGNORE_FILES "/\\\\.git/;\\\\.swp$;\\\\.#;/#;\\\\.*~;cscope\\\\.*;/[Bb]uild[.+-_a-zA-Z0-9]*/")
# default binary package settings
set (CPACK_INCLUDE_TOPLEVEL_DIRECTORY TRUE)
set (CPACK_PACKAGE_FILE_NAME "${CPACK_PACKAGE_NAME}-${CPACK_PACKAGE_VERSION}-${CPACK_SYSTEM_NAME}")
if (CMAKE_SYSTEM_PROCESSOR)
set (CPACK_PACKAGE_FILE_NAME "${CPACK_PACKAGE_FILE_NAME}-${CMAKE_SYSTEM_PROCESSOR}")
endif ()
# generator specific configuration file
#
# allow package maintainers to use their own configuration file
# $ cmake -DCPACK_PROJECT_CONFIG_FILE:FILE=/path/to/package/config
if (NOT CPACK_PROJECT_CONFIG_FILE)
configure_file (
"${CMAKE_CURRENT_LIST_DIR}/cmake/package.cmake.in"
"${PROJECT_BINARY_DIR}/${PACKAGE_NAME}-package.cmake" @ONLY
)
set (CPACK_PROJECT_CONFIG_FILE "${PROJECT_BINARY_DIR}/${PACKAGE_NAME}-package.cmake")
endif ()
include (CPack)
endif () # BUILD_PACKAGING
...@@ -3,9 +3,9 @@ INSTALLING A BINARY DISTRIBUTION PACKAGE ...@@ -3,9 +3,9 @@ INSTALLING A BINARY DISTRIBUTION PACKAGE
======================================== ========================================
No official binary distribution packages are provided by the gflags developers. No official binary distribution packages are provided by the gflags developers.
There may, however, be binary packages available for your OS, in particular There may, however, be binary packages available for your OS at
for various flavors of Linux. Please consult the package repositories of your https://code.google.com/p/gflags/downloads/list. Please consult also the
Linux distribution to see if a binary package is available. package repositories of your Linux distribution.
For example on Debian/Ubuntu Linux, gflags can be installed using the For example on Debian/Ubuntu Linux, gflags can be installed using the
following command: following command:
......
This repository contains the C++ implementation of the commandline flags module
originally developed at Google. Documentation for this module is in doc/.
The python version of gflags is now a separate project.
See INSTALL for (generic) installation instructions.
A commandline flags library that allows for distributed flags.
This package contains a library that implements commandline flags
processing. As such it's a replacement for getopt(). It has increased
flexibility, including built-in support for C++ types like string, and
the ability to define flags in the source file in which they're used.
The devel package contains static and debug libraries and header files
for developing applications that use the gflags package.
This package contains runtime libraries only which are required
by applications that use these libraries for the commandline flags
processing. If you want to develop such application, download
and install the development package instead.
# Per-generator CPack configuration file. See CPACK_PROJECT_CONFIG_FILE documented at
# http://www.cmake.org/cmake/help/v2.8.12/cpack.html#variable:CPACK_PROJECT_CONFIG_FILE
#
# All common CPACK_* variables are set in CMakeLists.txt already. This file only
# overrides some of these to provide package generator specific settings.
# whether package contains all development files or only runtime files
set (DEVEL @INSTALL_HEADERS@)
# ------------------------------------------------------------------------------
# Mac OS X package
if (CPACK_GENERATOR MATCHES "PackageMaker|DragNDrop")
set (CPACK_PACKAGE_FILE_NAME "${CPACK_PACKAGE_NAME}")
if (DEVEL)
set (CPACK_PACKAGE_FILE_NAME "${CPACK_PACKAGE_FILE_NAME}-devel")
endif ()
set (CPACK_PACKAGE_FILE_NAME "${CPACK_PACKAGE_FILE_NAME}-${CPACK_PACKAGE_VERSION}")
# ------------------------------------------------------------------------------
# Debian package
elseif ("^${CPACK_GENERATOR}$" STREQUAL "DEB")
set (CPACK_PACKAGE_FILE_NAME "lib${CPACK_PACKAGE_NAME}")
if (DEVEL)
set (CPACK_PACKAGE_FILE_NAME "${CPACK_PACKAGE_FILE_NAME}-dev")
else ()
set (CPACK_PACKAGE_FILE_NAME "${CPACK_PACKAGE_FILE_NAME}0")
endif ()
set (CPACK_PACKAGE_FILE_NAME "${CPACK_PACKAGE_FILE_NAME}_${CPACK_PACKAGE_VERSION}-1_${CMAKE_SYSTEM_PROCESSOR}")
execute_process (
COMMAND dpkg --print-architecture
RESULT_VARIABLE RV
OUTPUT_VARIABLE CPACK_DEBIAN_PACKAGE_ARCHITECTURE
)
if (NOT RV EQUAL 0)
set (CPACK_DEBIAN_PACKAGE_ARCHITECTURE i386)
endif ()
set (CPACK_DEBIAN_PACKAGE_DEPENDS)
set (CPACK_DEBIAN_PACKAGE_SECTION devel)
set (CPACK_DEBIAN_PACKAGE_PRIORITY optional)
# ------------------------------------------------------------------------------
# RPM package
elseif ("^${CPACK_GENERATOR}$" STREQUAL "RPM")
set (CPACK_PACKAGE_FILE_NAME "${CPACK_PACKAGE_NAME}")
if (DEVEL)
set (CPACK_PACKAGE_FILE_NAME "${CPACK_PACKAGE_FILE_NAME}-devel")
endif ()
set (CPACK_PACKAGE_FILE_NAME "${CPACK_PACKAGE_FILE_NAME}-${CPACK_PACKAGE_VERSION}-1_${CMAKE_SYSTEM_PROCESSOR}")
endif ()
...@@ -86,8 +86,10 @@ ...@@ -86,8 +86,10 @@
// --------------------------------------------------------------------------- // ---------------------------------------------------------------------------
// Windows // Windows
// Whether gflags library is shared. // Whether gflags library is a DLL.
#define GFLAGS_IS_A_DLL @GFLAGS_IS_A_DLL@ #ifndef GFLAGS_IS_A_DLL
# define GFLAGS_IS_A_DLL 0
#endif
// Always export symbols when compiling a shared library as this file is only // Always export symbols when compiling a shared library as this file is only
// included by internal modules when building the gflags library itself. // included by internal modules when building the gflags library itself.
......
...@@ -12,7 +12,17 @@ set (GFLAGS_FLAGFILES_DIR "${CMAKE_CURRENT_SOURCE_DIR}") ...@@ -12,7 +12,17 @@ set (GFLAGS_FLAGFILES_DIR "${CMAKE_CURRENT_SOURCE_DIR}")
# ---------------------------------------------------------------------------- # ----------------------------------------------------------------------------
# common include directories and link libraries # common include directories and link libraries
include_directories ("${CMAKE_CURRENT_SOURCE_DIR}") include_directories ("${CMAKE_CURRENT_SOURCE_DIR}")
link_libraries (gflags_nothreads)
if (BUILD_SHARED_LIBS)
set (type shared)
else ()
set (type static)
endif ()
if (BUILD_gflags_LIB)
link_libraries (gflags-${type})
else ()
link_libraries (gflags_nothreads-${type})
endif ()
# ---------------------------------------------------------------------------- # ----------------------------------------------------------------------------
# STRIP_FLAG_HELP # STRIP_FLAG_HELP
...@@ -35,7 +45,7 @@ add_executable (gflags_unittest gflags_unittest.cc) ...@@ -35,7 +45,7 @@ add_executable (gflags_unittest gflags_unittest.cc)
add_executable (gflags_unittest-main gflags_unittest-main.cc) add_executable (gflags_unittest-main gflags_unittest-main.cc)
add_executable (gflags_unittest_main gflags_unittest_main.cc) add_executable (gflags_unittest_main gflags_unittest_main.cc)
if (WIN32 AND NOT CYGWIN) if (OS_WINDOWS)
set (SLASH "\\\\") set (SLASH "\\\\")
else () else ()
set (SLASH "/") set (SLASH "/")
...@@ -146,11 +156,11 @@ add_gflags_test(always_fail 1 "ERROR: failed validation of new value 'true' for ...@@ -146,11 +156,11 @@ add_gflags_test(always_fail 1 "ERROR: failed validation of new value 'true' for
# ---------------------------------------------------------------------------- # ----------------------------------------------------------------------------
# (negative) compilation tests # (negative) compilation tests
if (BUILD_NEGATIVE_COMPILATION_TESTS) if (BUILD_NC_TESTS)
find_package (PythonInterp) find_package (PythonInterp)
if (NOT PYTHON_EXECUTABLE) if (NOT PYTHON_EXECUTABLE)
message (FATAL_ERROR "No Python installation found! It is required by the negative compilation tests." message (FATAL_ERROR "No Python installation found! It is required by the negative compilation tests."
" Either install Python or set NEGATIVE_COMPILATION_TESTS to FALSE and try again.") " Either install Python or set BUILD_NC_TESTS to FALSE and try again.")
endif () endif ()
set (SRCDIR "${CMAKE_CURRENT_SOURCE_DIR}/nc") set (SRCDIR "${CMAKE_CURRENT_SOURCE_DIR}/nc")
configure_file (gflags_nc.py.in "${CMAKE_RUNTIME_OUTPUT_DIRECTORY}/nc.py" @ONLY) configure_file (gflags_nc.py.in "${CMAKE_RUNTIME_OUTPUT_DIRECTORY}/nc.py" @ONLY)
...@@ -165,4 +175,4 @@ if (BUILD_NEGATIVE_COMPILATION_TESTS) ...@@ -165,4 +175,4 @@ if (BUILD_NEGATIVE_COMPILATION_TESTS)
add_gflags_nc_test (int_instead_of_bool) add_gflags_nc_test (int_instead_of_bool)
add_gflags_nc_test (bool_in_quotes) add_gflags_nc_test (bool_in_quotes)
add_gflags_nc_test (define_string_with_0) add_gflags_nc_test (define_string_with_0)
endif () endif ()
\ No newline at end of file
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment