Skip to content

Commit

Permalink
Use CMake
Browse files Browse the repository at this point in the history
  • Loading branch information
evanlin96069 committed May 3, 2024
1 parent ba9f1a3 commit 78e7fca
Show file tree
Hide file tree
Showing 2 changed files with 91 additions and 1 deletion.
2 changes: 1 addition & 1 deletion .gitignore
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
.vscode/
release/
debug/
*.txt
build/

resources/bundler
resources/bundler.exe
Expand Down
90 changes: 90 additions & 0 deletions CMakeLists.txt
Original file line number Diff line number Diff line change
@@ -0,0 +1,90 @@
cmake_minimum_required(VERSION 3.22.0)

project(nino VERSION 0.0.1 LANGUAGES C)

include(GNUInstallDirs)

set(CMAKE_C_STANDARD 11)

set(RESOURCE_DIR "${CMAKE_CURRENT_LIST_DIR}/resources")

set (SYNTAX_FILES
${RESOURCE_DIR}/syntax/c.json
${RESOURCE_DIR}/syntax/cpp.json
${RESOURCE_DIR}/syntax/java.json
${RESOURCE_DIR}/syntax/json.json
${RESOURCE_DIR}/syntax/make.json
${RESOURCE_DIR}/syntax/python.json
${RESOURCE_DIR}/syntax/rust.json
${RESOURCE_DIR}/syntax/zig.json
)

set (BUNDLER_SOURCE "${RESOURCE_DIR}/bundler.c")

add_executable(bundler ${BUNDLER_SOURCE})

set (BUNDLER_BIN $<TARGET_FILE:bundler>)
set (BUNDLED_FILE "${RESOURCE_DIR}/bundle.h")

add_custom_command(
OUTPUT ${BUNDLED_FILE}
COMMAND ${BUNDLER_BIN} ${BUNDLED_FILE} ${SYNTAX_FILES}
DEPENDS bundler ${SYNTAX_FILES}
WORKING_DIRECTORY ${CMAKE_CURRENT_LIST_DIR}
)

set (CORE_SOURCES
src/action.c
src/action.h
src/config.c
src/config.h
src/defines.h
src/editor.c
src/editor.h
src/file_io.c
src/file_io.h
src/highlight.c
src/highlight.h
src/input.c
src/input.h
src/json.h
src/nino.c
src/os.h
src/output.c
src/output.h
src/prompt.c
src/prompt.h
src/row.c
src/row.h
src/select.c
src/select.h
src/terminal.c
src/terminal.h
src/unicode.c
src/unicode.h
src/utils.c
src/utils.h
src/version.h
)

if (WIN32)
list(APPEND CORE_SOURCES
src/os_win32.c
src/os_win32.h
)
else()
list(APPEND CORE_SOURCES
src/os_unix.c
src/os_unix.h
)
endif()

add_executable(${PROJECT_NAME} ${CORE_SOURCES} ${BUNDLED_FILE})

if (MSVC)
target_compile_options(${PROJECT_NAME} PRIVATE /W4)
else()
target_compile_options(${PROJECT_NAME} PRIVATE -Wall -Wextra -pedantic)
endif()

install(TARGETS ${PROJECT_NAME})

0 comments on commit 78e7fca

Please sign in to comment.