Skip to content

Commit ab78a1f

Browse files
committed
Cleanup CMakeLists a bit
1 parent c9bdaad commit ab78a1f

File tree

9 files changed

+26
-47
lines changed

9 files changed

+26
-47
lines changed

CMakeLists.txt

Lines changed: 12 additions & 19 deletions
Original file line numberDiff line numberDiff line change
@@ -1,32 +1,22 @@
1-
cmake_minimum_required(VERSION 3.10)
1+
cmake_minimum_required(VERSION 3.19)
22

33
include(cmake/tools.cmake)
44
update_submodule(vcpkg)
5+
set_policies()
56

67
set(CMAKE_TOOLCHAIN_FILE vcpkg/scripts/buildsystems/vcpkg.cmake)
78

8-
cmake_policy(SET CMP0091 NEW)
9-
set(CMAKE_MSVC_RUNTIME_LIBRARY "MultiThreaded$<$<CONFIG:Debug>:Debug>")
10-
11-
cmake_policy(SET CMP0075 NEW)
12-
139
# Get version from vcpkg.json manifest
14-
find_program(PYTHON "python3")
15-
if(NOT PYTHON)
16-
find_program(PYTHON "python")
17-
endif()
10+
file(READ "${CMAKE_SOURCE_DIR}/vcpkg.json" VCPKG_MANIFEST_JSON)
1811

19-
if(NOT PYTHON)
20-
message(WARNING "Python is not found")
21-
endif()
22-
23-
execute_process(COMMAND ${PYTHON} ${CMAKE_SOURCE_DIR}/version.py
24-
get -f ${CMAKE_SOURCE_DIR}/vcpkg.json
25-
OUTPUT_VARIABLE VCPKG_MANIFEST_PROJECT_VERSION
26-
ERROR_VARIABLE VCPKG_VERSION_ERROR)
12+
string(JSON
13+
VCPKG_MANIFEST_PROJECT_VERSION
14+
ERROR_VARIABLE VCPKG_VERSION_ERROR
15+
GET ${VCPKG_MANIFEST_JSON} "version")
2716

2817
if(VCPKG_VERSION_ERROR)
2918
message(WARNING ${VCPKG_VERSION_ERROR})
19+
set(VCPKG_MANIFEST_PROJECT_VERSION "0.0.0")
3020
endif()
3121

3222
# Enable vcpkg features
@@ -45,9 +35,12 @@ if(ENABLE_BENCHMARKS)
4535
endif()
4636

4737
# Setup project
48-
cmake_policy(SET CMP0048 NEW)
4938
project(easy_reflection VERSION ${VCPKG_MANIFEST_PROJECT_VERSION})
5039

40+
set(CMAKE_CXX_STANDARD 17)
41+
set(CMAKE_EXPORT_COMPILE_COMMANDS ON)
42+
set(CMAKE_CXX_STANDARD_INCLUDE_DIRECTORIES ${CMAKE_CXX_IMPLICIT_INCLUDE_DIRECTORIES})
43+
5144
include(Dart)
5245
enable_testing()
5346

benchmarks/CMakeLists.txt

Lines changed: 1 addition & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1,13 +1,9 @@
1-
cmake_minimum_required(VERSION 3.10)
1+
cmake_minimum_required(VERSION 3.19)
22

33
project(benchmarks VERSION ${CMAKE_PROJECT_VERSION})
44

55
add_definitions(-DPROJECT_ROOT="${CMAKE_CURRENT_SOURCE_DIR}")
66

7-
set(CMAKE_CXX_STANDARD 17)
8-
set(CMAKE_EXPORT_COMPILE_COMMANDS ON)
9-
set(CMAKE_CXX_STANDARD_INCLUDE_DIRECTORIES ${CMAKE_CXX_IMPLICIT_INCLUDE_DIRECTORIES})
10-
117
disable_attribute_warnings()
128

139
set(CMAKE_RUNTIME_OUTPUT_DIRECTORY ${CMAKE_SOURCE_DIR}/output)

cmake/tools.cmake

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -98,6 +98,14 @@ function(disable_attribute_warnings)
9898
endif()
9999
endfunction()
100100

101+
# Helper function to set all policies
102+
function(set_policies)
103+
cmake_policy(SET CMP0075 NEW) # required library macro
104+
cmake_policy(SET CMP0048 NEW) # project version
105+
cmake_policy(SET CMP0091 NEW) # MSVC runtime library
106+
set(CMAKE_MSVC_RUNTIME_LIBRARY "MultiThreaded$<$<CONFIG:Debug>:Debug>")
107+
endfunction()
108+
101109
# Print variables that match the optional parameter.
102110
# Arguments:
103111
# FILTER - print only variables matching this string, print all if it's empty

example/CMakeLists.txt

Lines changed: 1 addition & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1,11 +1,7 @@
1-
cmake_minimum_required(VERSION 3.10)
1+
cmake_minimum_required(VERSION 3.19)
22

33
project(example VERSION ${CMAKE_PROJECT_VERSION})
44

5-
set(CMAKE_CXX_STANDARD 17)
6-
set(CMAKE_EXPORT_COMPILE_COMMANDS ON)
7-
set(CMAKE_CXX_STANDARD_INCLUDE_DIRECTORIES ${CMAKE_CXX_IMPLICIT_INCLUDE_DIRECTORIES})
8-
95
disable_attribute_warnings()
106

117
set(CMAKE_RUNTIME_OUTPUT_DIRECTORY ${CMAKE_SOURCE_DIR}/output)

generator/CMakeLists.txt

Lines changed: 1 addition & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1,11 +1,7 @@
1-
cmake_minimum_required(VERSION 3.10)
1+
cmake_minimum_required(VERSION 3.19)
22

33
project(er_gen VERSION ${CMAKE_PROJECT_VERSION})
44

5-
set(CMAKE_CXX_STANDARD 17)
6-
set(CMAKE_EXPORT_COMPILE_COMMANDS ON)
7-
set(CMAKE_CXX_STANDARD_INCLUDE_DIRECTORIES ${CMAKE_CXX_IMPLICIT_INCLUDE_DIRECTORIES})
8-
95
if(MSVC)
106
add_compile_options("$<$<NOT:$<CONFIG:DEBUG>>:/Ox>")
117
else()

library/CMakeLists.txt

Lines changed: 1 addition & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,10 +1,7 @@
1-
cmake_minimum_required(VERSION 3.10)
1+
cmake_minimum_required(VERSION 3.19)
22

33
project(reflection VERSION ${CMAKE_PROJECT_VERSION})
44

5-
set(CMAKE_CXX_STANDARD 17)
6-
set(CMAKE_EXPORT_COMPILE_COMMANDS ON)
7-
85
include_directories(include)
96

107
set(SOURCES

readme/installation.md

Lines changed: 0 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -30,7 +30,6 @@ Visual Studio CMake generators do not create `compile_commands.json`. However, y
3030
To build `er_gen` and use reflection on Windows, make sure to install the following dependencies and add them to your `PATH`:
3131

3232
- Git
33-
- Python
3433
- CMake
3534
- Ninja
3635

@@ -47,8 +46,6 @@ This repository includes a `Dockerfile` that sets up an `Ubuntu 22.04` environme
4746

4847
Another submodule is [vcpkg](https://github.com/microsoft/vcpkg) which manages most of the dependencies, all of them will be installed by CMake automatically.
4948

50-
> **Note:** You need **Python** to obtain project version from `vcpkg.json` manifest file. You probably already have it, please install it otherwise.
51-
5249
After installing all the dependencies, you need to decide whether you want to use `simdjson` for parsing or not. While `simdjson` provides the fastest performance on supported hardware, `rapidjson` might be faster in virtual environments. The solution includes a native parser that is available regardless. It offers more flexibility when it comes to map parsing but not as fast.
5350

5451
If, for some reason, you want to exclude `simdjson` from the dependencies, you can use the following **CMake** option:

tests/CMakeLists.txt

Lines changed: 1 addition & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1,14 +1,10 @@
1-
cmake_minimum_required(VERSION 3.10)
1+
cmake_minimum_required(VERSION 3.19)
22

33
project(tests VERSION ${CMAKE_PROJECT_VERSION})
44

55
add_definitions(-DPROJECT_ROOT="${CMAKE_CURRENT_SOURCE_DIR}")
66
add_definitions(-DREPEATS=1000)
77

8-
set(CMAKE_CXX_STANDARD 17)
9-
set(CMAKE_EXPORT_COMPILE_COMMANDS ON)
10-
set(CMAKE_CXX_STANDARD_INCLUDE_DIRECTORIES ${CMAKE_CXX_IMPLICIT_INCLUDE_DIRECTORIES})
11-
128
disable_attribute_warnings()
139

1410
set(CMAKE_RUNTIME_OUTPUT_DIRECTORY ${CMAKE_SOURCE_DIR}/output)

vcpkg.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
{
22
"name": "reflection-cpp",
3-
"version": "3.0.0",
3+
"version": "3.1.0",
44
"default-features": [
55
"library"
66
],

0 commit comments

Comments
 (0)