80 lines
1.9 KiB
CMake
80 lines
1.9 KiB
CMake
cmake_minimum_required(VERSION 3.31)
|
|
project(log-e-sappho C)
|
|
|
|
set(CMAKE_C_STANDARD 99)
|
|
set(CMAKE_C_STANDARD_REQUIRED True)
|
|
string(JOIN " " CMAKE_C_FLAGS
|
|
"-Wall -Wextra -Wformat=2"
|
|
"-Wconversion -Wsign-conversion -Wimplicit-fallthrough"
|
|
"-Werror=implicit"
|
|
"-Werror=incompatible-pointer-types"
|
|
"-Werror=int-conversion")
|
|
set(CMAKE_VERBOSE_MAKEFILE ON)
|
|
|
|
set(CMAKE_EXPORT_COMPILE_COMMANDS ON)
|
|
|
|
|
|
include(CheckSymbolExists)
|
|
|
|
set(INCLUDE_DIR include)
|
|
set(SRC_DIR src)
|
|
|
|
set(SPHO_HEADER_DIR ${INCLUDE_DIR}/spho)
|
|
|
|
set(SPHO_HEADER
|
|
${SPHO_HEADER_DIR}/bind.h
|
|
${SPHO_HEADER_DIR}/ctx.h
|
|
${SPHO_HEADER_DIR}/err.h
|
|
${SPHO_HEADER_DIR}/scope.h
|
|
${SPHO_HEADER_DIR}/spho.h
|
|
${SPHO_HEADER_DIR}/subt.h
|
|
${SPHO_HEADER_DIR}/tp.h
|
|
)
|
|
|
|
set(SPHO_SRC
|
|
${SRC_DIR}/spho/bind.c
|
|
${SRC_DIR}/spho/ctx.c
|
|
${SRC_DIR}/spho/scope.c
|
|
${SRC_DIR}/spho/subt.c
|
|
${SRC_DIR}/spho/tp.c
|
|
)
|
|
|
|
check_symbol_exists(strlcpy "string.h" HAVE_STRLCPY)
|
|
|
|
add_library(spho STATIC ${SPHO_HEADER} ${SPHO_SRC})
|
|
target_include_directories(spho PRIVATE ${INCLUDE_DIR})
|
|
target_compile_definitions(spho PRIVATE
|
|
$<$<CONFIG:Debug>:SPHO_DEBUG>
|
|
$<$<BOOL:${HAVE_STRLCPY}>:SPHO_USE_STRLCPY>
|
|
)
|
|
|
|
add_executable(devcheck ${SRC_DIR}/run/devcheck.c)
|
|
target_link_libraries(devcheck spho)
|
|
target_include_directories(devcheck PRIVATE ${INCLUDE_DIR})
|
|
target_compile_definitions(devcheck PRIVATE
|
|
$<$<CONFIG:Debug>:SPHO_DEBUG>
|
|
)
|
|
|
|
|
|
set(MSPH_SRC
|
|
${SRC_DIR}/msph/msph.c
|
|
${SRC_DIR}/msph/sphophi.c
|
|
${SRC_DIR}/msph/token.c
|
|
${SRC_DIR}/msph/tree.c
|
|
)
|
|
|
|
set(MSPH_HEADER
|
|
${INCLUDE_DIR}/msph/common.h
|
|
${INCLUDE_DIR}/msph/err.h
|
|
${INCLUDE_DIR}/msph/sphophi.h
|
|
${INCLUDE_DIR}/msph/token.h
|
|
${INCLUDE_DIR}/msph/tree.h
|
|
)
|
|
|
|
add_executable(msph ${MSPH_SRC} ${MSPH_HEADER})
|
|
target_include_directories(msph PRIVATE ${INCLUDE_DIR})
|
|
target_link_libraries(msph spho)
|
|
target_compile_definitions(msph PRIVATE
|
|
$<$<CONFIG:Debug>:SPHO_DEBUG>
|
|
$<$<BOOL:${HAVE_STRLCPY}>:SPHO_USE_STRLCPY>
|
|
)
|