Skip to content

Commit 3c5850c

Browse files
author
Requiem
committed
2.4.0 Update - Phase I
1 parent 4664aa1 commit 3c5850c

18 files changed

+1217
-14470
lines changed

CMakeLists.txt

Lines changed: 32 additions & 35 deletions
Original file line numberDiff line numberDiff line change
@@ -6,35 +6,42 @@ project(
66
LANGUAGES CXX
77
)
88

9-
10-
# set c++ standard
9+
# set C++ standard
1110
if(NOT DEFINED CMAKE_CXX_STANDARD)
1211
set(CMAKE_CXX_STANDARD 20)
1312
endif()
14-
15-
16-
# compiler flags
1713
set(CMAKE_CXX_STANDARD_REQUIRED ON)
1814
set(CMAKE_CXX_EXTENSIONS OFF)
1915

16+
if(MSVC)
17+
# Globally disable specific MSVC warnings from external headers
18+
add_compile_options(
19+
/wd5039 # 'TpSetCallbackCleanupGroup' potentially throwing
20+
/wd4820 # padding added after data member
21+
/wd4626 # deleted assignment operator
22+
/wd5045 # Spectre mitigation notice
23+
/wd4668 # undefined macro replaced with '0'
24+
)
25+
endif()
26+
27+
# compiler flags
2028
if (MSVC)
2129
set(CMAKE_CXX_FLAGS "/Wall /W4 /EHsc")
2230
else()
23-
# linux and apple
31+
# Linux and Apple
2432
set(CMAKE_CXX_FLAGS "-Wextra -Wall -Wextra -Wconversion -Wdouble-promotion -Wno-unused-parameter -Wno-unused-function -Wno-sign-conversion")
2533
endif()
2634

2735
if(CMAKE_C_COMPILER_ID STREQUAL "Clang" OR CMAKE_C_COMPILER_ID STREQUAL "GNU")
2836
set(CMAKE_CXX_FLAGS "${CMAKE_C_FLAGS} -lstdc++ -lm")
2937
endif()
3038

31-
3239
# find available compilers
3340
if (LINUX)
3441
find_program(CLANGPP_EXECUTABLE NAMES clang++)
3542
find_program(GPP_EXECUTABLE NAMES g++)
3643

37-
# select compiler with preference for clang++ (just a personal choice of mine, i'm kinda obsessed with llvm honestly)
44+
# select compiler with preference for clang++
3845
if(CLANGPP_EXECUTABLE)
3946
set(CMAKE_CXX_COMPILER "${CLANGPP_EXECUTABLE}")
4047
get_filename_component(COMPILER_NAME ${CLANGPP_EXECUTABLE} NAME)
@@ -45,67 +52,59 @@ if (LINUX)
4552
endif()
4653

4754
message(STATUS "Compiler: ${COMPILER_NAME}")
48-
#message(STATUS "Compiler version: ${CMAKE_CXX_COMPILER_VERSION}")
49-
50-
5155

5256
# fetch and set build type
5357
set(available_build_types Debug Release)
5458
if(NOT CMAKE_BUILD_TYPE)
55-
set(CMAKE_BUILD_TYPE Release CACHE STRING "Choose the type of build (Debug or Release)" FORCE)
59+
set(CMAKE_BUILD_TYPE Release CACHE STRING "Choose the type of build (Debug or Release)" FORCE)
5660
endif()
5761

58-
5962
# Define preprocessor macros based on the build type
6063
if(CMAKE_BUILD_TYPE STREQUAL "Debug")
61-
add_compile_definitions(__VMAWARE_DEBUG__)
64+
add_compile_definitions(__VMAWARE_DEBUG__)
6265
elseif(CMAKE_BUILD_TYPE STREQUAL "Release")
63-
add_compile_definitions(__VMAWARE_RELEASE__)
66+
add_compile_definitions(__VMAWARE_RELEASE__)
6467
endif()
6568

66-
6769
# general variables
6870
set(PROJECT_DIR "${CMAKE_CURRENT_SOURCE_DIR}")
6971
set(BUILD_DIR "${PROJECT_DIR}/build")
7072
set(TARGET "vmaware")
7173

72-
7374
# debug/release CXX flag options
7475
if (MSVC)
7576
if(CMAKE_BUILD_TYPE MATCHES "Debug")
76-
MESSAGE(STATUS "Build set to debug mode")
77+
message(STATUS "Build set to debug mode")
7778
elseif(CMAKE_BUILD_TYPE MATCHES "Release")
78-
MESSAGE(STATUS "Build set to release mode")
79+
message(STATUS "Build set to release mode")
7980
set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} /O2")
8081
endif()
8182
elseif(APPLE)
8283
if(CMAKE_BUILD_TYPE MATCHES "Debug")
83-
MESSAGE(STATUS "Build set to debug mode")
84+
message(STATUS "Build set to debug mode")
8485
set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -g -O0 -fsanitize=address")
8586
elseif(CMAKE_BUILD_TYPE MATCHES "Release")
86-
MESSAGE(STATUS "Build set to release mode")
87-
set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -g0 -O2")
88-
set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -march=native -mtune=native")
87+
message(STATUS "Build set to release mode")
88+
set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -g0 -O2 -march=native -mtune=native")
8989
endif()
9090
elseif(LINUX)
9191
if(CMAKE_BUILD_TYPE MATCHES "Debug")
92-
MESSAGE(STATUS "Build set to debug mode")
93-
set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -g -fmax-errors=5 -DDEBUG -O0 -fsanitize=address,leak") # todo, add ubsan
92+
message(STATUS "Build set to debug mode")
93+
set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -g -fmax-errors=5 -DDEBUG -O0 -fsanitize=address,leak")
9494
elseif(CMAKE_BUILD_TYPE MATCHES "Release")
95-
MESSAGE(STATUS "Build set to release mode")
95+
message(STATUS "Build set to release mode")
9696
set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -g0 -O2")
97-
if (${CMAKE_SYSTEM_PROCESSOR} MATCHES "x86_64")
97+
if(${CMAKE_SYSTEM_PROCESSOR} MATCHES "x86_64")
9898
set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -march=native -mtune=native")
9999
elseif(${CMAKE_SYSTEM_PROCESSOR} MATCHES "arm")
100100
set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -mcpu=native")
101101
endif()
102102
endif()
103103
else()
104-
MESSAGE(STATUS "Build set to release mode")
104+
message(STATUS "Build set to release mode")
105105
set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -O2")
106106
endif()
107107

108-
109108
# add executable
110109
set(CMAKE_RUNTIME_OUTPUT_DIRECTORY "${BUILD_DIR}")
111110
add_executable(${TARGET} "src/cli.cpp")
@@ -114,19 +113,17 @@ if(NOT DEFINED CMAKE_CXX_STANDARD)
114113
endif()
115114
set_property(TARGET ${TARGET} PROPERTY CXX_STANDARD_REQUIRED ON)
116115

117-
118116
# CTest stuff
119117
include(CTest)
120118
enable_testing()
121119
set(ARGUMENTS "--all")
122120
if(MSVC)
123-
add_test(executable, "${BUILD_DIR}/Release/${TARGET}")
121+
add_test(executable "${BUILD_DIR}/Release/${TARGET}")
124122
else()
125-
add_test(NAME TARGET COMMAND "${BUILD_DIR}/${TARGET}" ${ARGUMENTS})
123+
add_test(NAME TARGET COMMAND "${BUILD_DIR}/${TARGET}" ${ARGUMENTS})
126124
endif()
127125

128-
129-
# release stuff
126+
# install rules
130127
if (NOT MSVC)
131128
if(CMAKE_BUILD_TYPE MATCHES "Release")
132129
install(TARGETS ${TARGET} DESTINATION /usr/bin)
@@ -142,4 +139,4 @@ elseif(MSVC)
142139
set(HEADER_INSTALL_PATH "C:\\Program Files (x86)\\YourLibrary\\include")
143140
install(FILES "src/vmaware.hpp" DESTINATION "${HEADER_INSTALL_PATH}")
144141
install(FILES "src/vmaware_MIT.hpp" DESTINATION "${HEADER_INSTALL_PATH}")
145-
endif()
142+
endif()

CONTRIBUTING.md

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -13,9 +13,8 @@ You can create an issue, and I will reply within 24 hours. We have too much free
1313

1414

1515
## Extra
16-
We have a tool that can update the MIT file and other details of the library with a python script for maintenance purposes. The script at `auxiliary/updater.py` will update:
16+
We have an useful script at `auxiliary/updater.py` will update:
1717
- the section line numbers in the header banner
1818
- the date of the update
19-
- the MIT file by copying the GPL file and removing every GPL code (so that you don't have to make the same changes on 2 different files separately, just focus on vmaware.hpp and let the script manage the vmaware_MIT.hpp file)
2019

2120
It's highly recommended to use this script before sending the PR so that all the above don't have to be manually updated, which can be time consuming and can potentially creep in some human errors.

0 commit comments

Comments
 (0)