From 2e07715a7dc71f392d8af147c3e730b910633b18 Mon Sep 17 00:00:00 2001 From: cpunch Date: Thu, 11 Feb 2021 20:34:04 -0600 Subject: [PATCH] Added CMake support should make integration into visual studio easier for people --- .gitignore | 3 ++- CMakeLists.txt | 20 ++++++++++++++++++++ Makefile | 2 +- src/main.c => main.c | 0 src/cobj.c | 1 + src/cparse.c | 1 + 6 files changed, 25 insertions(+), 2 deletions(-) create mode 100644 CMakeLists.txt rename src/main.c => main.c (100%) diff --git a/.gitignore b/.gitignore index b68696e..72feb53 100644 --- a/.gitignore +++ b/.gitignore @@ -1,3 +1,4 @@ *.o bin -.vscode \ No newline at end of file +.vscode +CMakeFiles \ No newline at end of file diff --git a/CMakeLists.txt b/CMakeLists.txt new file mode 100644 index 0000000..801a61f --- /dev/null +++ b/CMakeLists.txt @@ -0,0 +1,20 @@ +cmake_minimum_required(VERSION 3.10) +project(cosmo VERSION 0.1.0 LANGUAGES C) + +set(CMAKE_C_STANDARD 11) +set(CMAKE_C_STANDARD_REQUIRED True) +set(CMAKE_DISABLE_SOURCE_CHANGES ON CACHE BOOL "Prevent writing files to CMAKE_SOURCE_DIR under configure") +set(CMAKE_RUNTIME_OUTPUT_DIRECTORY bin) + +set (CMAKE_C_FLAGS_DEBUG "${CMAKE_CXX_FLAGS_DEBUG} -g -Wall") +set (CMAKE_LINKER_FLAGS_DEBUG "${CMAKE_LINKER_FLAGS_DEBUG} -fsanitize=address") +set (CMAKE_C_FLAGS_RELEASE "${CMAKE_C_FLAGS_RELEASE} -O3 -Wall") + +include(FetchContent) + +file(GLOB sources CONFIGURE_DEPENDS ${PROJECT_SOURCE_DIR}/src/*.c) +add_executable(${PROJECT_NAME} main.c) +target_sources(${PROJECT_NAME} PRIVATE ${sources}) +target_link_libraries(${PROJECT_NAME} m) +target_include_directories(${PROJECT_NAME} PUBLIC ${PROJECT_SOURCE_DIR}/src) +target_compile_features(${PROJECT_NAME} PRIVATE c_std_11) diff --git a/Makefile b/Makefile index 90f9d79..1e8c509 100644 --- a/Makefile +++ b/Makefile @@ -33,7 +33,7 @@ CSRC=\ src/cvm.c\ src/cobj.c\ src/cbaselib.c\ - src/main.c\ + main.c\ COBJ=$(CSRC:.c=.o) diff --git a/src/main.c b/main.c similarity index 100% rename from src/main.c rename to main.c diff --git a/src/cobj.c b/src/cobj.c index bb8ae58..3da6e87 100644 --- a/src/cobj.c +++ b/src/cobj.c @@ -6,6 +6,7 @@ #include "clex.h" #include +#include // we don't actually hash the whole string :eyes: uint32_t hashString(const char *str, size_t sz) { diff --git a/src/cparse.c b/src/cparse.c index 7a835db..8250560 100644 --- a/src/cparse.c +++ b/src/cparse.c @@ -7,6 +7,7 @@ #include "cvm.h" #include +#include // we define all of this here because we only need it in this file, no need for it to be in the header /shrug