Skip to content
Projects
Groups
Snippets
Help
Loading...
Help
Support
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in / Register
Toggle navigation
A
actor-incubator
Project overview
Project overview
Details
Activity
Releases
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Issues
0
Issues
0
List
Boards
Labels
Milestones
Merge Requests
0
Merge Requests
0
CI / CD
CI / CD
Pipelines
Jobs
Schedules
Analytics
Analytics
CI / CD
Repository
Value Stream
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
cpp-libs
actor-incubator
Commits
50b0ab12
Commit
50b0ab12
authored
Mar 12, 2020
by
Jakob Otto
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Rework CMake-scaffold
parent
87d4ebdd
Changes
2
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
34 additions
and
117 deletions
+34
-117
CMakeLists.txt
CMakeLists.txt
+11
-100
configure
configure
+23
-17
No files found.
CMakeLists.txt
View file @
50b0ab12
# -- project setup -------------------------------------------------------------
cmake_minimum_required
(
VERSION 3.0 FATAL_ERROR
)
project
(
caf_incubator C
C
XX
)
project
(
caf_incubator CXX
)
# -- project options -----------------------------------------------------------
...
...
@@ -10,12 +10,10 @@ option(BUILD_SHARED_LIBS "Build all modules as shared library" ON)
# -- includes ------------------------------------------------------------------
include
(
CMakePackageConfigHelpers
)
# For creating .cmake files
include
(
CheckCSourceCompiles
)
# Check whether compiler works
include
(
CheckCSourceRuns
)
# Check whether compiler produces binaries
include
(
CheckCXXSourceCompiles
)
# Check wether compiler works
include
(
GNUInstallDirs
)
# Sets default install paths
include
(
GenerateExportHeader
)
# Auto-generates dllexport macros
# -- project-specific CMake settings -------------------------------------------
set
(
CMAKE_MODULE_PATH
"
${
CMAKE_CURRENT_SOURCE_DIR
}
/cmake"
)
...
...
@@ -165,19 +163,6 @@ endif()
# utility functions #
################################################################################
# Appends `str` to the variable named `var` with a whitespace as separator.
# Suppresses a leading whitespace if the variable is empty and does nothing if
# `str` is empty.
function
(
build_string var str
)
if
(
NOT str STREQUAL
""
)
if
(
"
${${
var
}}
"
STREQUAL
""
)
set
(
"
${
var
}
"
"
${
str
}
"
PARENT_SCOPE
)
else
()
set
(
"
${
var
}
"
"
${${
var
}}
${
str
}
"
PARENT_SCOPE
)
endif
()
endif
()
endfunction
(
build_string
)
# Forces `var` to 'no' if the content of the variables evaluates to false.
function
(
pretty_no var
)
if
(
NOT
"
${${
var
}}
"
)
...
...
@@ -266,42 +251,6 @@ endif()
# -- compiler setup ------------------------------------------------------------
# Enable a ton of warnings if --more-clang-warnings is used.
if
(
CAF_MORE_WARNINGS
)
if
(
CMAKE_CXX_COMPILER_ID MATCHES
"Clang"
)
set
(
WFLAGS
"-Weverything -Wno-c++98-compat -Wno-padded "
"-Wno-documentation-unknown-command -Wno-exit-time-destructors "
"-Wno-global-constructors -Wno-missing-prototypes "
"-Wno-c++98-compat-pedantic -Wno-unused-member-function "
"-Wno-unused-const-variable -Wno-switch-enum "
"-Wno-abstract-vbase-init -Wno-shadow "
"-Wno-missing-noreturn -Wno-covered-switch-default"
)
elseif
(
CMAKE_CXX_COMPILER_ID MATCHES
"GNU"
)
set
(
WFLAGS
"-Waddress -Wall -Warray-bounds "
"-Wattributes -Wbuiltin-macro-redefined -Wcast-align "
"-Wcast-qual -Wchar-subscripts -Wclobbered -Wcomment "
"-Wconversion -Wconversion-null -Wcoverage-mismatch "
"-Wcpp -Wdelete-non-virtual-dtor -Wdeprecated "
"-Wdeprecated-declarations -Wdiv-by-zero -Wdouble-promotion "
"-Wempty-body -Wendif-labels -Wenum-compare -Wextra "
"-Wfloat-equal -Wformat -Wfree-nonheap-object "
"-Wignored-qualifiers -Winit-self "
"-Winline -Wint-to-pointer-cast -Winvalid-memory-model "
"-Winvalid-offsetof -Wlogical-op -Wmain -Wmaybe-uninitialized "
"-Wmissing-braces -Wmultichar "
"-Wnarrowing -Wnoexcept -Wnon-template-friend "
"-Wnon-virtual-dtor -Wnonnull -Woverflow "
"-Woverlength-strings -Wparentheses "
"-Wpmf-conversions -Wpointer-arith -Wreorder "
"-Wreturn-type -Wsequence-point "
"-Wsign-compare -Wswitch -Wtype-limits -Wundef "
"-Wuninitialized -Wunused -Wvla -Wwrite-strings"
)
endif
()
# convert CMake list to a single string, erasing the ";" separators
string
(
REPLACE
";"
""
WFLAGS_STR
${
WFLAGS
}
)
build_string
(
"EXTRA_FLAGS"
"
${
WFLAGS_STR
}
"
)
endif
()
# Enable ASAN if requested by the user.
if
(
CAF_SANITIZERS
)
add_compile_options
(
"-fsanitize=
${
CAF_SANITIZERS
}
"
...
...
@@ -311,18 +260,18 @@ endif()
# -pthread is ignored on MacOSX but required on other platforms
if
(
NOT APPLE AND NOT WIN32
)
build_string
(
"EXTRA_FLAGS"
"-pthread"
)
add_compile_options
(
-pthread
)
list
(
APPEND CAF_EXTRA_LDFLAGS
"-pthread"
)
endif
()
# -fPIC generates warnings on MinGW and Cygwin plus extra setup steps needed on MinGW
if
(
MINGW
)
add_definitions
(
-D_WIN32_WINNT=0x0600
)
add_definitions
(
-DWIN32
)
add_definitions
(
-D_WIN32_WINNT=0x0600 -DWIN32
)
list
(
APPEND CAF_EXTRA_LDFLAGS -lws2_32 -liphlpapi -lpsapi
)
# build static to avoid runtime dependencies to GCC libraries
build_string
(
"EXTRA_FLAGS"
"-static"
)
add_compile_options
(
-static
)
elseif
(
CYGWIN
)
build_string
(
"EXTRA_FLAGS"
"-U__STRICT_ANSI__"
)
add_compile_options
(
-U__STRICT_ANSI__
)
endif
()
# Add Windows-specific linker flags.
...
...
@@ -338,45 +287,12 @@ endif()
# Add iOS target if requested by user.
if
(
CAF_IOS_DEPLOYMENT_TARGET
)
if
(
CAF_OSX_SYSROOT STREQUAL
"iphonesimulator"
)
build_string
(
"EXTRA_FLAGS"
"-mios-simulator-version-min=
${
CAF_IOS_DEPLOYMENT_TARGET
}
"
)
add_compile_options
(
"-mios-simulator-version-min=
${
CAF_IOS_DEPLOYMENT_TARGET
}
"
)
else
()
build_string
(
"EXTRA_FLAGS"
"-miphoneos-version-min=
${
CAF_IOS_DEPLOYMENT_TARGET
}
"
)
add_compile_options
(
"-miphoneos-version-min=
${
CAF_IOS_DEPLOYMENT_TARGET
}
"
)
endif
()
endif
()
# -- check if the user provided CXXFLAGS, set defaults otherwise ---------------
if
(
NOT CMAKE_CXX_FLAGS
)
set
(
CMAKE_CXX_FLAGS
"-Wextra -Wall -pedantic
${
EXTRA_FLAGS
}
"
)
endif
()
if
(
NOT CMAKE_CXX_FLAGS_DEBUG
)
set
(
CMAKE_CXX_FLAGS_DEBUG
"-O0 -g"
)
endif
()
if
(
NOT CMAKE_CXX_FLAGS_MINSIZEREL
)
set
(
CMAKE_CXX_FLAGS_MINSIZEREL
"-Os"
)
endif
()
if
(
NOT CMAKE_CXX_FLAGS_RELEASE
)
set
(
CMAKE_CXX_FLAGS_RELEASE
"-O3 -DNDEBUG"
)
endif
()
if
(
NOT CMAKE_CXX_FLAGS_RELWITHDEBINFO
)
set
(
CMAKE_CXX_FLAGS_RELWITHDEBINFO
"-O2 -g -fno-omit-frame-pointer"
)
endif
()
if
(
NOT CMAKE_BUILD_TYPE
)
set
(
CMAKE_BUILD_TYPE RelWithDebInfo
)
endif
()
# needed by subprojects
if
(
DEFINED CMAKE_LD_LIBS
)
list
(
APPEND
${
CMAKE_LD_LIBS
}
)
endif
()
# -- install targets -----------------------------------------------------------
# Process cmake_uninstall.cmake.in.
...
...
@@ -435,12 +351,7 @@ endmacro()
# Invert CAF_NO_* variables for nicer output.
invertYesNo
(
CAF_NO_UNIT_TESTS CAF_BUILD_UNIT_TESTS
)
# Collect all compiler flags.
string
(
TOUPPER
"
${
CMAKE_BUILD_TYPE
}
"
UPPER_BUILD_TYPE
)
set
(
ALL_CXX_FLAGS
"
${
CMAKE_CXX_FLAGS
}
${
CMAKE_CXX_FLAGS_
${
UPPER_BUILD_TYPE
}}
"
)
set
(
ALL_LD_FLAGS
"
${
CMAKE_SHARED_LINKER_FLAGS
}
${
CAF_EXTRA_LDFLAGS
}
"
)
string
(
STRIP
"
${
ALL_LD_FLAGS
}
"
ALL_LD_FLAGS
)
get_property
(
all_cxx_flags DIRECTORY PROPERTY COMPILE_OPTIONS
)
# Print summary.
if
(
NOT CAF_NO_SUMMARY
)
...
...
@@ -452,7 +363,7 @@ if(NOT CAF_NO_SUMMARY)
"
\n
Build static runtime:
${
CAF_BUILD_STATIC_RUNTIME
}
"
"
\n
"
"
\n
CXX:
${
CMAKE_CXX_COMPILER
}
"
"
\n
CXXFLAGS:
${
ALL_CXX_FLAGS
}
"
"
\n
CXXFLAGS:
${
all_cxx_flags
}
"
"
\n
LINKER_FLAGS (shared):
${
ALL_LD_FLAGS
}
"
"
\n
"
"
\n
Source directory:
${
CMAKE_CURRENT_SOURCE_DIR
}
"
...
...
configure
View file @
50b0ab12
...
...
@@ -2,15 +2,6 @@
# Convenience wrapper for easily viewing/setting options that
# the project's CMake scripts will recognize.
# check for `cmake` command
type
cmake
>
/dev/null 2>&1
||
{
echo
"
\
This package requires CMake, please install it first, then you may
use this configure script to access CMake equivalent functionality.
\
"
>
&2
;
exit
1
;
}
command
=
"
$0
$*
"
dirname_0
=
`
dirname
$0
`
sourcedir
=
`
cd
$dirname_0
&&
pwd
`
...
...
@@ -19,20 +10,20 @@ usage="\
Usage:
$0
[OPTION]... [VAR=VALUE]...
Build Options:
--cmake=PATH set a custom path to the CMake binary
--generator=GENERATOR set CMake generator (see cmake --help)
--build-type=TYPE set CMake build type [RelWithDebInfo]:
- Debug: debugging flags enabled
- MinSizeRel: minimal output size
- Release: optimizations on, debugging off
- RelWithDebInfo: release flags plus debugging
--extra-flags=STRING additional compiler flags
--extra-flags=STRING additional compiler flags
(sets CMAKE_CXX_FLAGS)
--build-dir=DIR place build files in directory [build]
--bin-dir=DIR executable directory [build/bin]
--lib-dir=DIR library directory [build/lib]
--build-static build as static and shared library
--build-static-only build as static library only
--static-runtime build with static C++ runtime
--more-warnings enables most warnings
--no-compiler-check disable compiler version check
--no-auto-libc++ do not automatically enable libc++ for Clang
...
...
@@ -111,6 +102,9 @@ while [ $# -ne 0 ]; do
echo
"
${
usage
}
"
1>&2
exit
1
;;
--cmake
=
*
)
CMakeCommand
=
"
$optarg
"
;;
--generator
=
*
)
CMakeGenerator
=
"
$optarg
"
;;
...
...
@@ -120,9 +114,6 @@ while [ $# -ne 0 ]; do
--with-sanitizers
=
*
)
append_cache_entry CAF_SANITIZERS STRING
"
$optarg
"
;;
--more-warnings
)
append_cache_entry CAF_MORE_WARNINGS BOOL
yes
;;
--no-compiler-check
)
append_cache_entry CAF_NO_COMPILER_CHECK BOOL
yes
;;
...
...
@@ -143,7 +134,7 @@ while [ $# -ne 0 ]; do
append_cache_entry CMAKE_BUILD_TYPE STRING
"
$optarg
"
;;
--extra-flags
=
*
)
append_cache_entry
EXTRA
_FLAGS STRING
"
$optarg
"
append_cache_entry
CMAKE_CXX
_FLAGS STRING
"
$optarg
"
;;
--build-dir
=
*
)
builddir
=
"
$optarg
"
...
...
@@ -186,6 +177,21 @@ done
# -- CMake setup ---------------------------------------------------------------
# Check for `cmake` command.
if
[
-z
"
$CMakeCommand
"
]
;
then
# prefer cmake3 over "regular" cmake (cmake == cmake2 on RHEL)
if
command
-v
cmake3
>
/dev/null 2>&1
;
then
CMakeCommand
=
"cmake3"
elif
command
-v
cmake
>
/dev/null 2>&1
;
then
CMakeCommand
=
"cmake"
else
echo
"This package requires CMake, please install it first."
echo
"Then you may use this script to configure the CMake build."
echo
"Note: pass --cmake=PATH to use cmake in non-standard locations."
exit
1
;
fi
fi
CMakeDefaultCache
=
$CMakeCacheEntries
CMakeCacheEntries
=
$CMakeDefaultCache
...
...
@@ -214,9 +220,9 @@ fi
cd
"
$workdir
"
if
[
-n
"
$CMakeGenerator
"
]
;
then
cmake
-G
"
$CMakeGenerator
"
$CMakeCacheEntries
"
$sourcedir
"
"
$CMakeCommand
"
-G
"
$CMakeGenerator
"
$CMakeCacheEntries
"
$sourcedir
"
else
cmake
$CMakeCacheEntries
"
$sourcedir
"
"
$CMakeCommand
"
$CMakeCacheEntries
"
$sourcedir
"
fi
printf
"#!/bin/sh
\n\n
"
>
config.status
...
...
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment