Skip to content

Instantly share code, notes, and snippets.

@bolry
Created September 10, 2017 10:19
Show Gist options
  • Save bolry/5f957b3b9e7d92d685841fde1e677369 to your computer and use it in GitHub Desktop.
Save bolry/5f957b3b9e7d92d685841fde1e677369 to your computer and use it in GitHub Desktop.
CMake stuff
Example of settings to CMake I use
Overrides RelWithDebugInfo from '-O2' to '-Og'
Also sets TYPE to 'Debug'
And example of setting the Eclipse executable path.
alias ncmake='CXX=g++ CC=gcc cmake -DCMAKE_C_FLAGS_RELWITHDEBINFO="-Og -g -DNDEBUG" -DCMAKE_CXX_FLAGS_RELWITHDEBINFO="-Og -g -DNDEBUG" -DCMAKE_BUILD_TYPE=Debug -DCMAKE_ECLIPSE_MAKE_ARGUMENTS=-v -DCMAKE_ECLIPSE_EXECUTABLE=/home/bo/eclipse/cpp-mars/eclipse/eclipse -DCMAKE_ECLIPSE_VERSION:STRING="4.5 (Mars)" -G "Eclipse CDT4 - Ninja"'
@bolry
Copy link
Author

bolry commented Sep 12, 2017

Google Test and CMake automatic
https://crascit.com/2015/07/25/cmake-gtest/

@bolry
Copy link
Author

bolry commented Oct 21, 2017

From http://www.bitsnbites.eu/faster-c-builds/
Using gold:
if (UNIX AND NOT APPLE)
execute_process(COMMAND ${CMAKE_C_COMPILER} -fuse-ld=gold -Wl,--version ERROR_QUIET OUTPUT_VARIABLE ld_version)
if ("${ld_version}" MATCHES "GNU gold")
set(CMAKE_EXE_LINKER_FLAGS "${CMAKE_EXE_LINKER_FLAGS} -fuse-ld=gold -Wl,--disable-new-dtags")
set(CMAKE_SHARED_LINKER_FLAGS "${CMAKE_SHARED_LINKER_FLAGS} -fuse-ld=gold -Wl,--disable-new-dtags")
endif()
endif()

@bolry
Copy link
Author

bolry commented Nov 18, 2021

@bolry
Copy link
Author

bolry commented Dec 5, 2021

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment