Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Sign up
Appearance settings

Commit 9d94825

Browse files
Simplify cmake setup
* Merge SolutionTarget.cmake and CompilerSettings.cmake into single file * Require C++ standard
1 parent 840c061 commit 9d94825

File tree

32 files changed

+42
-134
lines changed

32 files changed

+42
-134
lines changed

‎code/CMakeLists.txt‎

Lines changed: 2 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -12,10 +12,8 @@ if( "${CMAKE_SOURCE_DIR}" STREQUAL "${CMAKE_BINARY_DIR}" )
1212
message( FATAL_ERROR "The tutorial code must be built out of source!" )
1313
endif()
1414

15-
# Include the test (hello world) project.
16-
add_subdirectory( hello )
17-
1815
# Include the exercises that (should) work on all platforms.
16+
add_subdirectory( hello )
1917
add_subdirectory( asan )
2018
add_subdirectory( atomic )
2119
add_subdirectory( callgrind )
@@ -33,6 +31,7 @@ add_subdirectory( operators )
3331
add_subdirectory( polymorphism )
3432
add_subdirectory( race )
3533
add_subdirectory( smartPointers )
34+
add_subdirectory( stl )
3635
add_subdirectory( templates )
3736
add_subdirectory( valgrind )
3837
add_subdirectory( variadic )
@@ -43,8 +42,3 @@ if( NOT MSVC )
4342
add_subdirectory( helgrind )
4443
add_subdirectory( python )
4544
endif()
46-
47-
# Include the gcc-only exercises.
48-
if( NOT APPLE AND NOT MSVC )
49-
add_subdirectory( stl )
50-
endif()

‎code/SolutionTarget.cmake‎

Lines changed: 0 additions & 7 deletions
This file was deleted.

‎code/asan/CMakeLists.txt‎

Lines changed: 1 addition & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,11 +1,9 @@
1-
21
# Set up the project.
32
cmake_minimum_required( VERSION 3.12 )
43
project( asan LANGUAGES CXX )
54

65
# Set up the compilation environment.
7-
include( "${CMAKE_CURRENT_SOURCE_DIR}/../CompilerSettings.cmake" )
8-
include( "${CMAKE_CURRENT_SOURCE_DIR}/../SolutionTarget.cmake" )
6+
include( "${CMAKE_CURRENT_SOURCE_DIR}/../common.cmake" )
97

108
# Create the user's executable.
119
add_executable( asan "asan.cpp" )

‎code/atomic/CMakeLists.txt‎

Lines changed: 1 addition & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,11 +1,9 @@
1-
21
# Set up the project.
32
cmake_minimum_required( VERSION 3.12 )
43
project( atomic LANGUAGES CXX )
54

65
# Set up the compilation environment.
7-
include( "${CMAKE_CURRENT_SOURCE_DIR}/../CompilerSettings.cmake" )
8-
include( "${CMAKE_CURRENT_SOURCE_DIR}/../SolutionTarget.cmake" )
6+
include( "${CMAKE_CURRENT_SOURCE_DIR}/../common.cmake" )
97

108
# Figure out how to use the platform's thread capabilities.
119
find_package( Threads REQUIRED )

‎code/callgrind/CMakeLists.txt‎

Lines changed: 1 addition & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -1,14 +1,9 @@
1-
21
# Set up the project.
32
cmake_minimum_required( VERSION 3.12 )
43
project( callgrind LANGUAGES CXX )
54

6-
set(CMAKE_CXX_STANDARD 17)
7-
set(CMAKE_CXX_STANDARD_REQUIRED ON)
8-
95
# Set up the compilation environment.
10-
include( "${CMAKE_CURRENT_SOURCE_DIR}/../CompilerSettings.cmake" )
11-
include( "${CMAKE_CURRENT_SOURCE_DIR}/../SolutionTarget.cmake" )
6+
include( "${CMAKE_CURRENT_SOURCE_DIR}/../common.cmake" )
127

138
# Create the user's executable.
149
add_executable( fibocrunch "fibocrunch.cpp" )
Lines changed: 11 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -1,19 +1,12 @@
1-
#
2-
# Small module used in every project to set up the default "compilation
3-
# environment".
4-
#
5-
61
# Guard this file against multiple inclusions.
7-
get_property( _compilersSet GLOBAL PROPERTY COMPILER_SETTINGS_DONE SET )
8-
if( _compilersSet )
9-
unset( _compilersSet )
2+
get_property( _common GLOBAL PROPERTY COMMON_DONE SET )
3+
if( _common )
4+
unset( _common )
105
return()
116
endif()
12-
set_property( GLOBAL PROPERTY COMPILER_SETTINGS_DONE TRUE )
13-
7+
set_property( GLOBAL PROPERTY COMMON_DONE TRUE )
148

15-
# Set up a Debug build type by default, if the user didn't ask for something
16-
# else.
9+
# Set up a Debug build type by default, if none was specified
1710
if( NOT CMAKE_BUILD_TYPE AND NOT CMAKE_CONFIGURATION_TYPES )
1811
set( CMAKE_BUILD_TYPE "Debug" CACHE
1912
STRING "Choose the type of build." FORCE )
@@ -23,6 +16,7 @@ endif()
2316

2417
# Use C++17 in the project by default, or as high of a value as possible.
2518
set( CMAKE_CXX_STANDARD 17 CACHE STRING "C++ standard to use" )
19+
set( CMAKE_CXX_STANDARD_REQUIRED ON )
2620
set( CMAKE_CXX_EXTENSIONS FALSE CACHE BOOL "(Dis)Allow C++ extensions" )
2721

2822
# Enable (almost) all warnings for the build.
@@ -32,3 +26,8 @@ if( ( "${CMAKE_CXX_COMPILER_ID}" STREQUAL "GNU" ) OR
3226
elseif( "${CMAKE_CXX_COMPILER_ID}" STREQUAL "MSVC" )
3327
set( CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} /W4" )
3428
endif()
29+
30+
# Trivial module to set up the "solution" target for all projects.
31+
if( NOT TARGET solution )
32+
add_custom_target( solution )
33+
endif()

‎code/concepts/CMakeLists.txt‎

Lines changed: 1 addition & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1,14 +1,10 @@
1-
21
# Set up the project.
32
cmake_minimum_required( VERSION 3.12 )
43
project( concepts LANGUAGES CXX )
54

65
# Set up the compilation environment.
7-
include( "${CMAKE_CURRENT_SOURCE_DIR}/../CompilerSettings.cmake" )
8-
include( "${CMAKE_CURRENT_SOURCE_DIR}/../SolutionTarget.cmake" )
9-
6+
include( "${CMAKE_CURRENT_SOURCE_DIR}/../common.cmake" )
107
set(CMAKE_CXX_STANDARD 20)
11-
set(CMAKE_CXX_STANDARD_REQUIRED ON)
128

139
# Create the user's executable.
1410
add_executable( concepts "concepts.cpp" )

‎code/condition_variable/CMakeLists.txt‎

Lines changed: 1 addition & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,11 +1,9 @@
1-
21
# Set up the project.
32
cmake_minimum_required( VERSION 3.12 )
43
project( condition_variable LANGUAGES CXX )
54

65
# Set up the compilation environment.
7-
include( "${CMAKE_CURRENT_SOURCE_DIR}/../CompilerSettings.cmake" )
8-
include( "${CMAKE_CURRENT_SOURCE_DIR}/../SolutionTarget.cmake" )
6+
include( "${CMAKE_CURRENT_SOURCE_DIR}/../common.cmake" )
97

108
# Figure out how to use the platform's thread capabilities.
119
find_package( Threads REQUIRED )

‎code/constness/CMakeLists.txt‎

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,10 +1,9 @@
1-
21
# Set up the project.
32
cmake_minimum_required( VERSION 3.12 )
43
project( constness LANGUAGES CXX )
54

65
# Set up the compilation environment.
7-
include( "${CMAKE_CURRENT_SOURCE_DIR}/../CompilerSettings.cmake" )
6+
include( "${CMAKE_CURRENT_SOURCE_DIR}/../common.cmake" )
87

98
# Create the user's executable.
109
add_executable( constplay "constplay.cpp" )

‎code/control/CMakeLists.txt‎

Lines changed: 1 addition & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,11 +1,9 @@
1-
21
# Set up the project.
32
cmake_minimum_required( VERSION 3.12 )
43
project( control LANGUAGES CXX )
54

65
# Set up the compilation environment.
7-
include( "${CMAKE_CURRENT_SOURCE_DIR}/../CompilerSettings.cmake" )
8-
include( "${CMAKE_CURRENT_SOURCE_DIR}/../SolutionTarget.cmake" )
6+
include( "${CMAKE_CURRENT_SOURCE_DIR}/../common.cmake" )
97

108
# Create the user's executable.
119
add_executable( control "control.cpp" )

0 commit comments

Comments
(0)

AltStyle によって変換されたページ (->オリジナル) /