2017-05-09 18:26:48 +02:00
|
|
|
# =============================================================================
|
2015-07-16 09:55:23 +02:00
|
|
|
# 2010 by KjellKod.cc. This is PUBLIC DOMAIN to use at your own risk and comes
|
|
|
|
# with no warranties. This code is yours to share, use and modify with no
|
|
|
|
# strings attached and no restrictions or obligations.
|
2016-01-24 13:27:52 +01:00
|
|
|
#
|
2015-07-16 09:55:23 +02:00
|
|
|
# For more information see g3log/LICENSE or refer refer to http://unlicense.org
|
2017-05-09 18:26:48 +02:00
|
|
|
# ==============================================================================
|
2015-07-16 09:55:23 +02:00
|
|
|
|
2016-01-24 13:27:52 +01:00
|
|
|
|
2011-11-17 11:26:02 +01:00
|
|
|
# Below are details for compiling on Windows and Linux
|
2014-10-03 09:03:56 +02:00
|
|
|
# by default only an example g3log binary is created
|
2011-11-17 11:26:02 +01:00
|
|
|
# the performance and unit tests creation can be enabled by switching their
|
|
|
|
# OPTIONs from OFF to ON --- See below at around line 110
|
2011-11-10 22:23:33 +01:00
|
|
|
|
2016-01-24 13:27:52 +01:00
|
|
|
# === WINDOWS ===
|
2014-02-26 06:05:48 +01:00
|
|
|
# Example for: Visual Studio 2013 (earlier should work too)
|
|
|
|
# 1. please use the "Visual Studio Command Prompt 12 (2013)"
|
2014-10-03 09:03:56 +02:00
|
|
|
# 2. from the g3log folder
|
2011-11-10 22:23:33 +01:00
|
|
|
# mkdir build
|
|
|
|
# cd build;
|
2014-10-03 09:53:21 +02:00
|
|
|
# 3. cmake -DCMAKE_BUILD_TYPE=Release -G "Visual Studio XXX" ..
|
2015-02-02 08:31:43 +01:00
|
|
|
# (cmake -DCMAKE_BUILD_TYPE=Release -G "Visual Studio 12")
|
2014-10-03 09:53:21 +02:00
|
|
|
# (XXX is the Visual Studio version you are running)
|
2014-10-03 09:03:56 +02:00
|
|
|
# 4. msbuild g3log.sln /p:Configuration=Release
|
2014-02-26 06:05:48 +01:00
|
|
|
#
|
|
|
|
# Try to run an example, such as:
|
2014-10-03 09:53:21 +02:00
|
|
|
# 5. Release\g3log-FATAL-contract.exe
|
2011-11-05 17:36:07 +01:00
|
|
|
#
|
|
|
|
#
|
2014-02-26 06:05:48 +01:00
|
|
|
|
2014-10-03 09:53:21 +02:00
|
|
|
# === LINUX: === To try this out from folder g3log:
|
2011-11-05 17:36:07 +01:00
|
|
|
# mkdir build
|
|
|
|
# cd build
|
2014-10-03 09:53:21 +02:00
|
|
|
# >> create makefiles in g3log/build directory
|
2016-01-24 13:27:52 +01:00
|
|
|
# cmake -DCMAKE_BUILD_TYPE=Release ..
|
|
|
|
# make -jN (where N stands for number of cores you want to utilize)
|
2014-02-26 06:05:48 +01:00
|
|
|
#
|
|
|
|
#
|
|
|
|
#
|
|
|
|
# === Clang on Linux ===
|
2014-10-03 09:53:21 +02:00
|
|
|
# From g3log
|
2014-02-26 06:05:48 +01:00
|
|
|
# mkdir build && cd build
|
|
|
|
# cmake -DCMAKE_CXX_COMPILER=clang++ ..
|
2016-01-24 13:27:52 +01:00
|
|
|
# if you want to double-check settings: "VERBOSE=1 make"
|
|
|
|
# otherwise just run: "make -j"
|
|
|
|
#
|
2011-11-05 17:36:07 +01:00
|
|
|
# ============================================================================
|
|
|
|
|
2016-10-17 19:49:56 +02:00
|
|
|
cmake_minimum_required (VERSION 3.1)
|
2012-06-02 22:04:28 +02:00
|
|
|
ENABLE_LANGUAGE(CXX)
|
2017-03-31 06:52:09 +02:00
|
|
|
|
2017-05-09 18:26:48 +02:00
|
|
|
if(NOT CMAKE_BUILD_TYPE AND NOT (MSVC_IDE OR XCODE))
|
2017-03-31 06:52:09 +02:00
|
|
|
set(CMAKE_BUILD_TYPE Release CACHE STRING "Build type, one of: Release, Debug" FORCE)
|
|
|
|
endif()
|
2017-05-09 18:26:48 +02:00
|
|
|
|
2012-06-02 22:04:28 +02:00
|
|
|
|
2014-10-03 09:03:56 +02:00
|
|
|
project (g3log)
|
|
|
|
|
2017-05-09 18:26:48 +02:00
|
|
|
message("Build type: ${CMAKE_BUILD_TYPE}")
|
|
|
|
message("Configuration types: ${CMAKE_CONFIGURATION_TYPES}")
|
|
|
|
|
2012-10-14 01:54:56 +02:00
|
|
|
# Detect 64 or 32 bit
|
|
|
|
if (CMAKE_SIZEOF_VOID_P EQUAL 8)
|
|
|
|
# 64-bit project
|
|
|
|
SET(64_BIT_OS TRUE)
|
|
|
|
MESSAGE("A 64-bit OS detected")
|
|
|
|
else()
|
|
|
|
SET(64_BIT_OS FALSE)
|
|
|
|
MESSAGE("A 32-bit OS detected")
|
|
|
|
endif()
|
2011-11-10 22:23:33 +01:00
|
|
|
|
2011-11-05 17:36:07 +01:00
|
|
|
|
2017-03-31 06:52:09 +02:00
|
|
|
SET(MAJOR_VERSION 1)
|
2017-04-01 18:39:34 +02:00
|
|
|
IF (${VERSION}.x STREQUAL ".x")
|
2017-05-04 02:49:11 +02:00
|
|
|
IF (MSVC)
|
|
|
|
message("windows: Extracting git software version")
|
2017-05-04 22:00:17 +02:00
|
|
|
execute_process(COMMAND powershell "(git rev-list --branches HEAD | Measure-Object -line).Lines" OUTPUT_VARIABLE GIT_VERSION WORKING_DIRECTORY ${CMAKE_SOURCE_DIR})
|
2017-05-04 02:49:11 +02:00
|
|
|
ELSE()
|
|
|
|
IF(UNIX OR ${CMAKE_SYSTEM_NAME} MATCHES "Darwin")
|
|
|
|
message("nix: Extracting git software version")
|
|
|
|
ELSE()
|
|
|
|
message("unknown platform: extracting git software version")
|
|
|
|
ENDIF()
|
2017-05-04 22:00:17 +02:00
|
|
|
execute_process(COMMAND bash "-c" "git rev-list --branches HEAD | wc -l | tr -d ' ' | tr -d '\n'" OUTPUT_VARIABLE GIT_VERSION WORKING_DIRECTORY ${CMAKE_SOURCE_DIR})
|
2017-05-04 02:49:11 +02:00
|
|
|
ENDIF()
|
|
|
|
|
2017-03-31 06:52:09 +02:00
|
|
|
SET(MINOR_VERSION 3)
|
2017-04-25 05:50:35 +02:00
|
|
|
math(EXPR VERSION-BASE ${GIT_VERSION}/255)
|
|
|
|
math(EXPR VERSION-REMAINDER ${GIT_VERSION}%255)
|
|
|
|
message("git build version: ${GIT_VERSION}")
|
|
|
|
message("version base: ${VERSION-BASE}")
|
|
|
|
message("version remainder: ${VERSION-REMAINDER}")
|
|
|
|
# SET(BUILD_NUMBER ${GIT_VERSION})
|
|
|
|
SET(BUILD_NUMBER ${VERSION-BASE})
|
|
|
|
SET(VERSION ${MAJOR_VERSION}.${MINOR_VERSION}.${BUILD_NUMBER}-${VERSION-REMAINDER})
|
2017-03-31 06:52:09 +02:00
|
|
|
ENDIF()
|
|
|
|
MESSAGE("Software Version: ${VERSION}")
|
|
|
|
|
|
|
|
|
2014-10-03 09:03:56 +02:00
|
|
|
|
|
|
|
# ============================================================================
|
2015-02-02 08:31:43 +01:00
|
|
|
# G3LOG OPTIONAL FEATURES
|
2014-10-03 09:03:56 +02:00
|
|
|
# ============================================================================
|
2015-02-02 08:31:43 +01:00
|
|
|
INCLUDE (${g3log_SOURCE_DIR}/Options.cmake)
|
2014-10-03 09:03:56 +02:00
|
|
|
|
2017-04-20 08:53:52 +02:00
|
|
|
# =========================================================================
|
|
|
|
# G3 Macro definitions in Options.cmake are written to file
|
|
|
|
# this avoids having to re-state your definitions in your source code
|
|
|
|
# or compile options
|
|
|
|
#==========================================================================
|
|
|
|
INCLUDE (${g3log_SOURCE_DIR}/GenerateMacroDefinitionsFile.cmake)
|
|
|
|
|
2013-12-10 22:57:04 +01:00
|
|
|
|
2015-09-06 13:22:04 +02:00
|
|
|
|
2015-07-13 15:49:44 +02:00
|
|
|
# =========================================================================
|
|
|
|
# G3LOG BUILD
|
|
|
|
#==========================================================================
|
|
|
|
INCLUDE (${g3log_SOURCE_DIR}/Build.cmake)
|
|
|
|
|
2016-01-24 13:27:52 +01:00
|
|
|
|
2011-11-10 22:23:33 +01:00
|
|
|
|
2013-12-10 22:57:04 +01:00
|
|
|
# ============================================================================
|
2014-10-03 09:03:56 +02:00
|
|
|
# EXAMPLE OPTIONS: By defauls is ON. This will create 'g3log-FATAL-* examples'
|
2013-12-10 22:57:04 +01:00
|
|
|
# ============================================================================
|
2016-01-24 13:27:52 +01:00
|
|
|
# DISABLE WITH: -DADD_FATAL_EXAMPLE=OFF
|
2014-10-03 09:03:56 +02:00
|
|
|
INCLUDE (${g3log_SOURCE_DIR}/example/Example.cmake)
|
2013-12-10 22:57:04 +01:00
|
|
|
|
2011-11-05 17:36:07 +01:00
|
|
|
|
|
|
|
|
2011-11-23 16:18:18 +01:00
|
|
|
# ============================================================================
|
2014-10-03 09:03:56 +02:00
|
|
|
# PERFORMANCE TEST OPTIONS: Performance operations for g3log
|
2011-11-23 16:18:18 +01:00
|
|
|
# ============================================================================
|
2016-01-24 13:27:52 +01:00
|
|
|
# ENABLE WITH: -DADD_G3LOG_PERFORMANCE=ON
|
2014-10-03 09:03:56 +02:00
|
|
|
INCLUDE (${g3log_SOURCE_DIR}/test_performance/Performance.cmake)
|
2013-12-10 22:57:04 +01:00
|
|
|
|
2016-01-24 13:27:52 +01:00
|
|
|
|
2014-10-03 09:03:56 +02:00
|
|
|
|
|
|
|
# ==========================================================================
|
2016-01-24 13:27:52 +01:00
|
|
|
# UNIT TEST OPTIONS:
|
2014-10-03 09:03:56 +02:00
|
|
|
# ============================================================================
|
2016-01-24 13:27:52 +01:00
|
|
|
# ENABLE WITH: -DADD_G3LOG_UNIT_TEST=ON
|
2014-10-03 09:03:56 +02:00
|
|
|
INCLUDE (${g3log_SOURCE_DIR}/test_unit/Test.cmake)
|
|
|
|
|
|
|
|
|
2017-04-20 08:53:52 +02:00
|
|
|
|
2014-10-03 09:03:56 +02:00
|
|
|
|
2016-12-22 17:30:18 +01:00
|
|
|
IF(${CMAKE_SYSTEM_NAME} MATCHES "Linux" OR ${CMAKE_SYSTEM_NAME} MATCHES "Darwin")
|
2016-03-06 23:55:35 +01:00
|
|
|
# ==========================================================================
|
|
|
|
# BETA : package manager for G3Log,. not yet reliable. Use at your own risk
|
|
|
|
# only tested on Ubuntu and CentOS
|
|
|
|
#
|
|
|
|
# For OSX you can install an older version using 'brew install'
|
|
|
|
#
|
|
|
|
# ==========================================================================
|
|
|
|
# Package handling is done AFTER all other CMake setup
|
|
|
|
# usage: make package
|
|
|
|
# Check the output result and install accordingly.
|
|
|
|
# ==========================================================================
|
|
|
|
INCLUDE (${g3log_SOURCE_DIR}/CPackLists.txt)
|
|
|
|
ENDIF()
|
2014-10-03 09:03:56 +02:00
|
|
|
|
2012-10-14 01:54:56 +02:00
|
|
|
|
2015-09-01 07:45:47 +02:00
|
|
|
IF (NOT MSVC)
|
|
|
|
MESSAGE("\n\n
|
|
|
|
*******************************************************************
|
2016-01-24 13:27:52 +01:00
|
|
|
Please do 'make clean-cmake' before next cmake generation.
|
|
|
|
It is a good idea to purge your build directory of CMake
|
2015-09-01 07:45:47 +02:00
|
|
|
generated cache files
|
|
|
|
*******************************************************************
|
|
|
|
")
|
|
|
|
add_custom_target(clean-cmake
|
|
|
|
COMMAND ${CMAKE_COMMAND} -P ${g3log_SOURCE_DIR}/CleanAll.cmake
|
|
|
|
)
|
|
|
|
ENDIF()
|
2015-07-16 09:55:23 +02:00
|
|
|
|
2011-11-10 22:23:33 +01:00
|
|
|
|
2011-11-17 11:26:02 +01:00
|
|
|
|
|
|
|
|
2011-11-05 17:36:07 +01:00
|
|
|
|