feat(build): setup basic cmake build system for c library

This commit is contained in:
Mineplay 2025-04-09 18:19:41 -05:00
parent 2e0df8aa37
commit f5d55b2655
3 changed files with 32 additions and 0 deletions

1
.gitignore vendored Normal file
View file

@ -0,0 +1 @@
Build

25
CMakeLists.txt Normal file
View file

@ -0,0 +1,25 @@
cmake_minimum_required(VERSION 3.10)
project(Hallocy C)
set(CMAKE_C_STANDARD 11)
set(CMAKE_C_STANDARD_REQUIRED ON)
include_directories(${PROJECT_SOURCE_DIR}/Include)
file(GLOB_RECURSE SRC_FILES "${PROJECT_SOURCE_DIR}/Src/*.c")
add_library(Hallocy STATIC ${SRC_FILES})
add_executable(HallocyApp ${PROJECT_SOURCE_DIR}/Src/Main.c)
target_link_libraries(HallocyApp Hallocy)
if (MSVC)
target_compile_options(Hallocy PRIVATE /W4 /Zl)
else()
target_compile_options(Hallocy PRIVATE -mavx512f -mavx512vl)
target_compile_options(HallocyApp PRIVATE -mavx512f -mavx512vl)
target_compile_options(Hallocy PRIVATE -march=native)
target_compile_options(HallocyApp PRIVATE -march=native)
target_compile_options(Hallocy PRIVATE -Wall -Wextra -pedantic)
endif()

6
Src/Main.c Normal file
View file

@ -0,0 +1,6 @@
#include <stdio.h>
int main() {
printf("Hello, World!\n");
return 0;
}