Created
July 28, 2023 19:43
-
-
Save Sharp0802/a9b4d73e3c68ce6207ba58bb6517ccdf to your computer and use it in GitHub Desktop.
Sample CMakeLists.txt for C++23
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
cmake_minimum_required(VERSION 3.20) | |
project(project LANGUAGES CXX) | |
set(CMAKE_VERBOSE_MAKEFILE TRUE) | |
set(CMAKE_CXX_STANDARD 23) | |
set(CMAKE_CXX_EXTENSIONS ON) | |
set(CMAKE_RUNTIME_OUTPUT_DIRECTORY ${CMAKE_CURRENT_LIST_DIR}/bin/) | |
set(CMAKE_ARCHIVE_OUTPUT_DIRECTORY ${CMAKE_CURRENT_LIST_DIR}/bin/) | |
set(CMAKE_LIBRARY_OUTPUT_DIRECTORY ${CMAKE_CURRENT_LIST_DIR}/bin/) | |
set(COMMON_FLAGS | |
-Os -Wall -Wextra | |
-ffunction-sections -fdata-sections | |
-fwhole-program -D __whopr__ | |
-fno-asynchronous-unwind-tables -fno-unwind-tables | |
-fno-plt -fno-ident | |
-march=native | |
) | |
add_compile_options( | |
${COMMON_FLAGS} | |
-fno-rtti #-fno-exceptions | |
) | |
add_link_options( | |
${COMMON_FLAGS} | |
-Wl,-z,norelro -Wl,-s -Wl,--build-id=none | |
) | |
file(GLOB_RECURSE SRC src/*.cc) | |
add_executable(project ${SRC}) | |
add_custom_command( | |
TARGET project | |
PRE_BUILD | |
COMMAND mkdir -p ${CMAKE_CURRENT_LIST_DIR}/bin/ && rm -rf ${CMAKE_CURRENT_LIST_DIR}/bin/* | |
) | |
target_include_directories(project PRIVATE inc) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Make it public!