MalachScript/CMakeLists.txt

35 lines
987 B
CMake
Raw Normal View History

cmake_minimum_required(VERSION 3.17)
2020-10-05 15:45:00 +00:00
project(MalachScript)
# Enable all warnings, and make them error when occurring.
add_compile_options(-Wall -Wextra -Werror)
# We like new stuff, so set the c++ standard to c++20.
set(CMAKE_CXX_STANDARD 20)
option(TESTS "Whether the test executable should be build as well." OFF)
if (CMAKE_CXX_COMPILER_ID STREQUAL "Clang")
add_link_options(-fuse-ld=lld)
endif ()
if (NOT WINDOWS)
# Include debug symbols in all linux builds
add_compile_options(-g -gfull -g3)
endif ()
file(GLOB_RECURSE SRC_FILES "src/*.cpp" "src/*.hpp")
2020-10-05 15:45:00 +00:00
add_library(MalachScript SHARED ${SRC_FILES})
if (TESTS)
# Create Test executable
file(GLOB_RECURSE TEST_FILES "tests/*.cpp" "tests/*.hpp")
2020-10-05 15:45:00 +00:00
add_executable(MalachScriptTests ${TEST_FILES} extern/doctest.hpp)
target_link_libraries(MalachScriptTests PUBLIC MalachScript)
# Add a definition for the test library
2020-10-05 15:45:00 +00:00
target_compile_definitions(MalachScriptTests PRIVATE TESTS_BUILD)
endif ()