Skip to content

Commit

Permalink
Static common lib
Browse files Browse the repository at this point in the history
  • Loading branch information
atirut-w committed Jan 28, 2024
1 parent 58721e4 commit f155642
Show file tree
Hide file tree
Showing 5 changed files with 21 additions and 25 deletions.
2 changes: 2 additions & 0 deletions CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,7 @@ set(SDCC_PATH "src/sdcc-build" CACHE STRING "Path to SDCC")
set(SDCC_VERSION "14210" CACHE STRING "SDCC version")

# Third-party libraries
add_subdirectory("ext/regex")
add_subdirectory("ext/Unity")

if(EXISTS "${CMAKE_SOURCE_DIR}/.git" AND EXISTS "/usr/bin/git")
Expand Down Expand Up @@ -66,6 +67,7 @@ if(BUILD_SDCC)
install(PROGRAMS ${PROJECT_SOURCE_DIR}/${SDCC_PATH}/src/sdcc DESTINATION bin RENAME z88dk-zsdcc)
endif()

add_subdirectory(src/common)
add_subdirectory(src/copt)
add_subdirectory(src/sccz80)
add_subdirectory(src/ucpp)
Expand Down
16 changes: 16 additions & 0 deletions src/common/CMakeLists.txt
Original file line number Diff line number Diff line change
@@ -0,0 +1,16 @@
add_library(common STATIC
"die.c"
"dirname.c"
"fileutil.c"
"objfile.c"
"option.c"
"optparse.c"
"stack_trace.c"
"strpool.c"
"strtable.c"
"strutil.c"
"xassert.c"
"xmalloc.c"
"z80asm_defs.c"
)
target_include_directories(common PUBLIC . "../../ext/uthash/src" "../../ext/optparse/" "../../ext/regex/")
8 changes: 1 addition & 7 deletions src/sccz80/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -19,16 +19,10 @@ add_executable(z88dk-sccz80
"sym.c"
"while.c"
"declparse.c"
"../common/option.c"
)

target_include_directories(z88dk-sccz80 PRIVATE
"../common"
"../../ext/uthash/src"
)

target_link_libraries(z88dk-sccz80 PRIVATE
m # This caught me so off guard
common
)

install(TARGETS z88dk-sccz80 DESTINATION bin)
13 changes: 1 addition & 12 deletions src/z80asm/CMakeLists.txt
Original file line number Diff line number Diff line change
@@ -1,8 +1,6 @@
# $(filter-out src/c/test.c, $(wildcard src/c/*.c ../common/*.c ../../ext/regex/reg*.c))
file(GLOB C_SRCS
"src/c/*.c"
"../common/*.c"
"../../ext/regex/reg*.c"
)
list(REMOVE_ITEM C_SRCS
"src/c/test.c"
Expand All @@ -17,20 +15,11 @@ add_executable(z88dk-z80asm
${CXX_SRCS}
)
target_include_directories(z88dk-z80asm PRIVATE
# Common stuff
"./"
"src/"
"../common/"

# Local stuff
"src/c/"
"t/"
"../../ext/optparse/"
"../../ext/regex/"
"../../ext/uthash/src/"

# Idk where this is declared from, so I'll put it here
"../../ext/Unity/src/"
)
target_compile_features(z88dk-z80asm PRIVATE cxx_std_17)
target_link_libraries(z88dk-z80asm PRIVATE common unity)
install(TARGETS z88dk-z80asm DESTINATION bin)
7 changes: 1 addition & 6 deletions src/zcc/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -5,18 +5,13 @@ add_executable(zcc
"../copt/regex/regerror.c"
"../copt/regex/regexec.c"
"../copt/regex/regfree.c"

"../common/dirname.c"
"../common/option.c"
)

target_include_directories(zcc PRIVATE
"."
"../copt"
"../common"
"../../ext/uthash/src"
)

target_compile_definitions(zcc PRIVATE LOCAL_REGEXP)
target_link_libraries(zcc PRIVATE common)

install(TARGETS zcc DESTINATION bin)

0 comments on commit f155642

Please sign in to comment.