More CMake stuff

FossilOrigin-Name: d07dcffeebdce3068ada45fb7be2479b36810b6970fa36803a7beb2ddc4667e2
This commit is contained in:
nekobit 2022-12-05 06:00:54 +00:00
parent d933f9fe02
commit bfda933431
5 changed files with 80 additions and 28 deletions

View File

@ -3,6 +3,7 @@
# cmake -DCMAKE_BUILD_TYPE=Debug ..
# cmake -DCMAKE_BUILD_TYPE=Release ..
# TODO Poke at this
cmake_minimum_required(VERSION 3.14)
project(treebird
VERSION 0.7
@ -10,9 +11,12 @@ project(treebird
LANGUAGES C)
include(cmake/os_hacks.cmake)
include(cmake/set_and_def.cmake)
find_package(FCGI REQUIRED)
find_package(PERL REQUIRED)
# List helper
include(cmake/append_and_def.cmake)
find_package(PkgConfig REQUIRED)
# Link stuff
pkg_check_modules(CURL libcurl REQUIRED)
find_package(PerlLibs REQUIRED)
# Useful for GNU Emacs or VS Code
set(CMAKE_EXPORT_COMPILE_COMMANDS ON)
@ -21,18 +25,67 @@ set(CMAKE_EXPORT_COMPILE_COMMANDS ON)
add_compile_options(
-Wall -Wextra -std=c99
-Wshadow -Wcast-align -Wstrict-prototypes
${PERL_EXTRA_C_FLAGS}
$<$<CONFIG:DEBUG>:-Og>
$<$<CONFIG:DEBUG>:-g>
$<$<CONFIG:RELEASE>:-O2>
)
)
# hack is on me
add_link_options(
-lmastodont
${CURL_LDFLAGS_OTHER}
)
include_directories(include)
# Read CMakeLists.txt in test file
add_subdirectory(test)
#add_subdirectory(test)
set_and_def(SRC_FILES
set(SRC_FILES
src/file-to-c/main.c
)
append_and_def(SRC_FILES
src/about.c
src/account.c
src/applications.c
src/attachments.c
src/base_page.c
src/conversations.c
src/cookie.c
src/easprintf.c
src/emoji.c
src/emoji_reaction.c
src/error.c
src/global_cache.c
src/global_perl.c
src/hashtag.c
src/helpers.c
src/http.c
src/index.c
src/key.c
src/lists.c
src/local_config.c
src/local_config_set.c
src/login.c
src/main.c
src/memory.c
src/memory_page.c
src/mime.c
src/notifications.c
src/page_config.c
src/path.c
src/query.c
src/request.c
src/scrobble.c
src/search.c
src/session.c
src/status.c
src/string.c
src/string_helpers.c
src/timeline.c
src/types.c
)
# Compile with X11
@ -44,7 +97,13 @@ if(X11_FOUND)
add_definitions(-DTREEBIRD_USE_X11_BACKEND)
endif(X11_FOUND)
add_executable(treebird SHARED ${SRC_FILES})
target_include_directories(treebird PUBLIC ${X11_xcb_INCLUDE_PATH})
add_executable(treebird ${SRC_FILES})
target_include_directories(treebird PUBLIC
${PERL_INCLUDE_PATH}
${CURL_INCLUDE_PATH})
# Build! Note the mastodont hack, this _should_ change soon.
target_link_libraries(treebird PUBLIC ${_LIB} mastodont-c/libmastodont.a)
target_link_libraries(treebird PUBLIC
${PERL_LIBRARIES}
${CURL_LIBRARIES}
mastodont-c/libmastodont.a)

View File

@ -0,0 +1,9 @@
# For ease of development, you can enable and disable pages. This is useful if
# the code doesn't compile correctly, for which you can do an `#ifdef' with the
# C Preprocessor
function(append_and_def NAME)
foreach(X IN ITEMS ARGV)
list(APPEND NAME X)
endforeach()
endfunction()

2
cmake/os_hacks.cmake Normal file
View File

@ -0,0 +1,2 @@
# TODO set some FreeBSD bullshit i gotta deal with

View File

@ -1,2 +0,0 @@
# For ease of development, you can enable and disable pages. This is useful if
# the code doesn't compile correctly, for which

View File

@ -1,16 +0,0 @@
/* BEGIN Status_test */
struct mstdnt_status status_test = {
.account = {
.avatar = "/treebird_logo.png",
.display_name = "Test user",
.acct = "user@test.com",
},
.content = "Hello world<br><br>Hi",
};
before_html = construct_status(&status_test, NULL);
stat_html = construct_status(&status_test, NULL);
after_html = construct_status(&status_test, NULL);
/* END Status_test */