2020-10-04 14:33:12 +00:00
|
|
|
cmake_minimum_required(VERSION 3.17)
|
2020-10-05 15:45:00 +00:00
|
|
|
project(MalachScript)
|
2020-10-04 14:33:12 +00:00
|
|
|
|
|
|
|
# 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)
|
2020-11-01 12:44:28 +00:00
|
|
|
option(STATICC "Whether gcc and stdc++ should be linked statically to the library." OFF)
|
2020-10-04 14:33:12 +00:00
|
|
|
|
|
|
|
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})
|
2020-10-04 14:33:12 +00:00
|
|
|
|
2020-11-01 12:44:28 +00:00
|
|
|
set(LINKS)
|
|
|
|
if (STATICC)
|
|
|
|
set(LINKS ${LINKS} -static-libgcc -static-libstdc++ -Wl,-Bstatic -lstdc++ -lpthread)
|
|
|
|
endif(STATICC)
|
|
|
|
target_link_libraries(MalachScript ${LINKS})
|
|
|
|
|
2020-10-04 14:33:12 +00:00
|
|
|
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)
|
2020-10-04 14:33:12 +00:00
|
|
|
|
|
|
|
# Add a definition for the test library
|
2020-10-05 15:45:00 +00:00
|
|
|
target_compile_definitions(MalachScriptTests PRIVATE TESTS_BUILD)
|
2020-10-04 14:33:12 +00:00
|
|
|
endif ()
|
|
|
|
|
|
|
|
|
|
|
|
|