Coder Social home page Coder Social logo

cmake-stuff's Introduction

cmake-stuff

CMake stuff for reuse across projects.

Setup test project

$ mkdir test-cmake-stuff; cd test-cmake-stuff; git init

# Fast way to bring up new CMake project
$ conan new -d name=test-cmake-stuff -d version=0.0.1 cmake_exe

$ git submodule add https://github.com/ooonak/cmake-stuff
$ cp cmake-stuff/templates/* .

# Add to top-level CMakeLists.txt
option(USE_HARDENING_FLAGS "Enable compiler hardening flags" ON)

list(APPEND CMAKE_MODULE_PATH "${CMAKE_CURRENT_SOURCE_DIR}/cmake-stuff/cmake")
include(scripts)

enable_tidy()
enable_cppcheck()
enable_iwyu()

set_warnings(WERROR)

# For x86_64 executable
set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -fPIE -fcf-protection=full -O2")
# For aarch64 shared library
#set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -fPIC -mbranch-protection=standard -O2")

message("${CMAKE_CXX_FLAGS}")
$ cmake -S . -B build -G Ninja -DCMAKE_BUILD_TYPE=Release -DCMAKE_CXX_COMPILER=clang++
$ cmake --build build

# Or just

$ conan build .
$ ./build/Release/test-cmake-stuff
test-cmake-stuff/0.0.1: Hello World Release!
  test-cmake-stuff/0.0.1: __x86_64__ defined
  test-cmake-stuff/0.0.1: _GLIBCXX_USE_CXX11_ABI 1
  test-cmake-stuff/0.0.1: __cplusplus201703
  test-cmake-stuff/0.0.1: __GNUC__13
  test-cmake-stuff/0.0.1: __GNUC_MINOR__2

cmake-stuff's People

Contributors

ooonak avatar

Watchers

 avatar

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.