]> git.seodisparate.com - c_simple_http/commitdiff
Add CMakeLists.txt, update .gitignore
authorStephen Seo <seo.disparate@gmail.com>
Fri, 6 Sep 2024 04:24:28 +0000 (13:24 +0900)
committerStephen Seo <seo.disparate@gmail.com>
Fri, 6 Sep 2024 04:24:28 +0000 (13:24 +0900)
.gitignore
CMakeLists.txt [new file with mode: 0644]

index 5b854f62f435c1cb55d556a3369e2d75e75d9b8b..21a9836a6600af87d001c7d8d2ca6c5d7910bfeb 100644 (file)
@@ -1,3 +1,4 @@
 /c_simple_http
 /objs/
 /unit_test
+/build*/
diff --git a/CMakeLists.txt b/CMakeLists.txt
new file mode 100644 (file)
index 0000000..4557af1
--- /dev/null
@@ -0,0 +1,81 @@
+cmake_minimum_required(VERSION 3.25)
+project(c_simple_http C)
+
+set(c_simple_http_SOURCES
+  "${CMAKE_CURRENT_SOURCE_DIR}/src/arg_parse.c"
+  "${CMAKE_CURRENT_SOURCE_DIR}/src/big_endian.c"
+  "${CMAKE_CURRENT_SOURCE_DIR}/src/tcp_socket.c"
+  "${CMAKE_CURRENT_SOURCE_DIR}/src/signal_handling.c"
+  "${CMAKE_CURRENT_SOURCE_DIR}/src/globals.c"
+  "${CMAKE_CURRENT_SOURCE_DIR}/src/http.c"
+  "${CMAKE_CURRENT_SOURCE_DIR}/src/config.c"
+  "${CMAKE_CURRENT_SOURCE_DIR}/src/http_template.c"
+  "${CMAKE_CURRENT_SOURCE_DIR}/third_party/SimpleArchiver/src/helpers.c"
+  "${CMAKE_CURRENT_SOURCE_DIR}/third_party/SimpleArchiver/src/data_structures/linked_list.c"
+  "${CMAKE_CURRENT_SOURCE_DIR}/third_party/SimpleArchiver/src/data_structures/hash_map.c"
+  "${CMAKE_CURRENT_SOURCE_DIR}/third_party/SimpleArchiver/src/data_structures/priority_heap.c"
+  "${CMAKE_CURRENT_SOURCE_DIR}/third_party/SimpleArchiver/src/algorithms/linear_congruential_gen.c"
+)
+
+if(NOT DEFINED CMAKE_BUILD_TYPE OR "${CMAKE_BUILD_TYPE}" STREQUAL "")
+    message("Defaulting to \"Debug\" build type.")
+    set(CMAKE_BUILD_TYPE "Debug" CACHE STRING "Build type" FORCE)
+else()
+    message("Using build type \"${CMAKE_BUILD_TYPE}\".")
+endif()
+
+add_executable(c_simple_http
+  ${c_simple_http_SOURCES}
+  "${CMAKE_CURRENT_SOURCE_DIR}/src/main.c"
+)
+target_include_directories(c_simple_http PUBLIC "${CMAKE_CURRENT_SOURCE_DIR}/third_party")
+
+add_executable(unit_tests
+  ${c_simple_http_SOURCES}
+  "${CMAKE_CURRENT_SOURCE_DIR}/src/test.c"
+)
+target_include_directories(unit_tests PUBLIC "${CMAKE_CURRENT_SOURCE_DIR}/third_party")
+
+target_compile_options(c_simple_http PUBLIC
+$<IF:$<CONFIG:Debug>,-Og,-fno-delete-null-pointer-checks -fno-strict-overflow -fno-strict-aliasing -ftrivial-auto-var-init=zero>
+-Wall -Wformat -Wformat=2 -Wconversion -Wimplicit-fallthrough
+-U_FORTIFY_SOURCE -D_FORTIFY_SOURCE=3
+-D_GLIBCXX_ASSERTIONS
+-fstrict-flex-arrays=3
+-fstack-clash-protection -fstack-protector-strong
+-fPIC
+)
+
+target_link_options(c_simple_http PUBLIC
+$<IF:$<CONFIG:Debug>,-Og,-fno-delete-null-pointer-checks -fno-strict-overflow -fno-strict-aliasing -ftrivial-auto-var-init=zero>
+-Wall -Wformat -Wformat=2 -Wconversion -Wimplicit-fallthrough
+-U_FORTIFY_SOURCE -D_FORTIFY_SOURCE=3
+-D_GLIBCXX_ASSERTIONS
+-fstrict-flex-arrays=3
+-fstack-clash-protection -fstack-protector-strong
+-Wl,-z,noexecstack
+-Wl,-z,relro -Wl,-z,now
+-fPIC
+)
+
+target_compile_options(unit_tests PUBLIC
+$<IF:$<CONFIG:Debug>,-Og,-fno-delete-null-pointer-checks -fno-strict-overflow -fno-strict-aliasing -ftrivial-auto-var-init=zero>
+-Wall -Wformat -Wformat=2 -Wconversion -Wimplicit-fallthrough
+-U_FORTIFY_SOURCE -D_FORTIFY_SOURCE=3
+-D_GLIBCXX_ASSERTIONS
+-fstrict-flex-arrays=3
+-fstack-clash-protection -fstack-protector-strong
+-fPIC
+)
+
+target_link_options(unit_tests PUBLIC
+$<IF:$<CONFIG:Debug>,-Og,-fno-delete-null-pointer-checks -fno-strict-overflow -fno-strict-aliasing -ftrivial-auto-var-init=zero>
+-Wall -Wformat -Wformat=2 -Wconversion -Wimplicit-fallthrough
+-U_FORTIFY_SOURCE -D_FORTIFY_SOURCE=3
+-D_GLIBCXX_ASSERTIONS
+-fstrict-flex-arrays=3
+-fstack-clash-protection -fstack-protector-strong
+-Wl,-z,noexecstack
+-Wl,-z,relro -Wl,-z,now
+-fPIC
+)