2020-07-10 18:06:26 +01:00
|
|
|
cmake_minimum_required(VERSION 3.16)
|
|
|
|
|
|
|
|
# Project name and a few useful settings. Other commands can pick up the results
|
|
|
|
project(Serene
|
|
|
|
VERSION 0.1.0
|
|
|
|
DESCRIPTION "Serene language is a modern Lisp."
|
|
|
|
LANGUAGES CXX)
|
|
|
|
|
2020-07-16 15:48:06 +01:00
|
|
|
set(CMAKE_EXPORT_COMPILE_COMMANDS 1)
|
2021-03-22 19:53:10 +00:00
|
|
|
|
2020-07-10 18:06:26 +01:00
|
|
|
# Only do these if this is the main project, and not if it is included through add_subdirectory
|
|
|
|
if(CMAKE_PROJECT_NAME STREQUAL PROJECT_NAME)
|
|
|
|
|
2020-07-23 17:13:16 +01:00
|
|
|
## Settings -----------------------------------------
|
|
|
|
# specify the C++ standard
|
|
|
|
set(CMAKE_CXX_STANDARD 20)
|
|
|
|
set(CMAKE_CXX_STANDARD_REQUIRED True)
|
2020-07-10 18:06:26 +01:00
|
|
|
|
2020-07-23 17:13:16 +01:00
|
|
|
set(INCLUDE_DIR ${CMAKE_SOURCE_DIR}/include)
|
|
|
|
set(SRC_DIR ${CMAKE_SOURCE_DIR}/src)
|
|
|
|
set(BIN_DIR ${CMAKE_SOURCE_DIR}/bin)
|
2020-07-10 18:06:26 +01:00
|
|
|
|
2020-07-23 17:13:16 +01:00
|
|
|
set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -Wall -Wextra -Werror")
|
2021-03-21 16:25:12 +00:00
|
|
|
set(CMAKE_CXX_CLANG_TIDY clang-tidy)
|
2020-07-23 17:13:16 +01:00
|
|
|
# Let's ensure -std=c++xx instead of -std=g++xx
|
|
|
|
set(CMAKE_CXX_EXTENSIONS OFF)
|
|
|
|
set(CMAKE_CXX_FLAGS_DEBUG
|
|
|
|
"${CMAKE_CXX_FLAGS_DEBUG} -g -fno-omit-frame-pointer -fsanitize=address")
|
|
|
|
set(CMAKE_LINKER_FLAGS_DEBUG
|
|
|
|
"${CMAKE_LINKER_FLAGS_DEBUG} -fno-omit-frame-pointer -fsanitize=address")
|
2020-07-10 18:06:26 +01:00
|
|
|
|
2020-07-23 17:13:16 +01:00
|
|
|
set(CMAKE_CXX_FLAGS_RELEASE
|
|
|
|
"${CMAKE_CXX_FLAGS_RELEASE} -O3")
|
2020-07-10 18:06:26 +01:00
|
|
|
|
2020-07-23 17:13:16 +01:00
|
|
|
set(CMAKE_MODULE_PATH "${CMAKE_SOURCE_DIR}/cmake")
|
|
|
|
set(MemoryCheckCommand "valgrind")
|
2020-07-10 18:06:26 +01:00
|
|
|
|
2021-03-22 19:53:10 +00:00
|
|
|
add_compile_options(-fno-rtti)
|
|
|
|
|
2020-07-23 17:13:16 +01:00
|
|
|
configure_file(${INCLUDE_DIR}/config.h.in config.h)
|
2020-07-10 18:06:26 +01:00
|
|
|
|
2020-07-23 17:13:16 +01:00
|
|
|
# Let's nicely support folders in IDEs
|
|
|
|
set_property(GLOBAL PROPERTY USE_FOLDERS ON)
|
2020-07-10 18:06:26 +01:00
|
|
|
|
2020-07-23 17:13:16 +01:00
|
|
|
## Options ------------------------------------------
|
|
|
|
option(ENABLE_LOG "Enable logging" OFF)
|
|
|
|
option(ENABLE_EXPR_LOG "Enable AExpr logging" OFF)
|
|
|
|
option(ENABLE_READER_LOG "Enable reader logging" OFF)
|
2020-07-10 18:06:26 +01:00
|
|
|
|
2020-07-23 17:13:16 +01:00
|
|
|
# Testing only available if this is the main app
|
|
|
|
# Note this needs to be done in the main CMakeLists
|
|
|
|
# since it calls enable_testing, which must be in the
|
|
|
|
# main CMakeLists.
|
|
|
|
include(CTest)
|
2020-07-10 18:06:26 +01:00
|
|
|
|
2020-07-23 17:13:16 +01:00
|
|
|
# Docs only available if this is the main app
|
|
|
|
find_package(Doxygen)
|
|
|
|
if(Doxygen_FOUND)
|
|
|
|
add_subdirectory(docs)
|
|
|
|
else()
|
|
|
|
message(STATUS "Doxygen not found, not building docs")
|
|
|
|
endif()
|
2020-07-10 18:06:26 +01:00
|
|
|
|
|
|
|
|
2020-07-23 17:13:16 +01:00
|
|
|
include(cotire)
|
|
|
|
include(FetchContent)
|
|
|
|
|
|
|
|
find_package(LLVM REQUIRED CONFIG)
|
|
|
|
|
|
|
|
message(STATUS "Found LLVM ${LLVM_PACKAGE_VERSION}")
|
|
|
|
message(STATUS "Using LLVMConfig.cmake in: ${LLVM_DIR}")
|
|
|
|
|
|
|
|
include_directories(${LLVM_INCLUDE_DIRS})
|
|
|
|
add_definitions(${LLVM_DEFINITIONS})
|
2020-07-10 18:06:26 +01:00
|
|
|
|
2020-07-23 17:13:16 +01:00
|
|
|
llvm_map_components_to_libnames(llvm_libs support core irreader)
|
2020-07-10 18:06:26 +01:00
|
|
|
|
2020-07-23 17:13:16 +01:00
|
|
|
# Formatting library
|
|
|
|
FetchContent_Declare(
|
|
|
|
fmtlib
|
|
|
|
GIT_REPOSITORY https://github.com/fmtlib/fmt.git
|
|
|
|
GIT_TAG 7.0.1
|
|
|
|
)
|
|
|
|
FetchContent_MakeAvailable(fmtlib)
|
2020-07-10 18:06:26 +01:00
|
|
|
|
2020-07-23 17:13:16 +01:00
|
|
|
|
|
|
|
# The compiled library code is here
|
|
|
|
add_subdirectory(src)
|
|
|
|
|
|
|
|
# The executable code is here
|
|
|
|
add_subdirectory(bin)
|
|
|
|
|
|
|
|
# Testing only available if this is the main app
|
|
|
|
# Emergency override SERENE_CMAKE_BUILD_TESTING provided as well
|
|
|
|
if((CMAKE_PROJECT_NAME STREQUAL PROJECT_NAME OR SERENE_CMAKE_BUILD_TESTING) AND BUILD_TESTING)
|
|
|
|
add_subdirectory(tests)
|
|
|
|
endif()
|
|
|
|
|
2021-03-22 19:53:10 +00:00
|
|
|
|
2020-07-23 17:13:16 +01:00
|
|
|
endif()
|