Skip to content

Commit

Permalink
Stop defaulting to the "RelWithDebInfo" build type
Browse files Browse the repository at this point in the history
The Nixpkgs build environment i.a. expects CMAKE_BUILD_TYPE to be an
empty string (which would set no optimization flags).
  • Loading branch information
axelf4 committed Apr 13, 2024
1 parent 188e2c6 commit 1b54d7a
Show file tree
Hide file tree
Showing 3 changed files with 11 additions and 15 deletions.
3 changes: 3 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
@@ -1,2 +1,5 @@
/.eldev
/Eldev-local

/build
/hotfuzz-module.so
19 changes: 6 additions & 13 deletions CMakeLists.txt
Original file line number Diff line number Diff line change
@@ -1,17 +1,10 @@
cmake_minimum_required(VERSION 3.19)
project(hotfuzz C)

if(NOT CMAKE_BUILD_TYPE AND NOT CMAKE_CONFIGURATION_TYPES)
message(STATUS "Setting build type to 'RelWithDebInfo' as none was specified.")
set(CMAKE_BUILD_TYPE "RelWithDebInfo" CACHE
STRING "Choose the type of build." FORCE)
endif()

find_program(EMACS_PROGRAM emacs)
if(EMACS_PROGRAM)
get_filename_component(EMACS_PROGRAM ${EMACS_PROGRAM} REALPATH)
get_filename_component(EMACS_PROGRAM_DIR ${EMACS_PROGRAM} DIRECTORY)
get_filename_component(EMACS_PROGRAM_DIR ${EMACS_PROGRAM_DIR} DIRECTORY)
find_program(EMACS_EXECUTABLE emacs)
if(EMACS_EXECUTABLE)
file(REAL_PATH ${EMACS_EXECUTABLE} EMACS_EXECUTABLE)
set(EMACS_PROGRAM_DIR ${EMACS_EXECUTABLE}/../..)
endif()

find_path(EMACS_INCLUDE_DIR emacs-module.h
Expand All @@ -26,8 +19,8 @@ find_package(Threads REQUIRED)
add_library(hotfuzz-module MODULE hotfuzz-module.c)
set_target_properties(hotfuzz-module PROPERTIES
C_STANDARD 11
POSITION_INDEPENDENT_CODE ON
C_STANDARD_REQUIRED ON
PREFIX ""
LIBRARY_OUTPUT_DIRECTORY ${CMAKE_SOURCE_DIR})
target_include_directories(hotfuzz-module PRIVATE ${EMACS_INCLUDE_DIR})
target_include_directories(hotfuzz-module SYSTEM PRIVATE ${EMACS_INCLUDE_DIR})
target_link_libraries(hotfuzz-module PRIVATE Threads::Threads)
4 changes: 2 additions & 2 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -55,8 +55,8 @@ and run
```sh
mkdir build
cd build
cmake -DCMAKE_C_FLAGS='-O3 -march=native' .. \
&& cmake --build .
cmake -DCMAKE_BUILD_TYPE=Release -DCMAKE_C_FLAGS=-march=native .. &&
cmake --build .
```

and place the resulting shared library somewhere in `load-path`.
Expand Down

0 comments on commit 1b54d7a

Please sign in to comment.