Skip to content

Commit

Permalink
updates cmakes to create bindings target in top-level
Browse files Browse the repository at this point in the history
  • Loading branch information
BlakeFreer committed Apr 4, 2024
1 parent cac3109 commit 6e2a181
Show file tree
Hide file tree
Showing 11 changed files with 10 additions and 25 deletions.
10 changes: 6 additions & 4 deletions firmware/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -54,21 +54,23 @@ set(CMAKE_CXX_STANDARD_INCLUDE_DIRECTORIES ${CMAKE_CXX_IMPLICIT_INCLUDE_DIRECTOR
set(CMAKE_CXX_EXTENSIONS ON)

project("${PROJECT}-${PLATFORM}")
set(CMAKE_EXPORT_COMPILE_COMMANDS ON)
set(CMAKE_C_USE_RESPONSE_FILE_FOR_INCLUDES OFF) # this doesn't seem to do anything yet

add_executable(main)
add_library(bindings)

add_subdirectory(${DIR_PROJECT}) # provides "main" (executable)
add_subdirectory(${DIR_PLATFORM}) # provides "bindings" (library)
add_subdirectory(${DIR_PROJECT}) # modifies "main" (executable)
add_subdirectory(${DIR_PLATFORM}) # modifies "bindings" (library)

target_include_directories(main
PUBLIC
${CMAKE_CURRENT_SOURCE_DIR}
${DIR_PLATFORM} # provides the platform-specific bindings header
)

target_include_directories(bindings
PRIVATE
${CMAKE_CURRENT_SOURCE_DIR} # provides app.h
${CMAKE_CURRENT_SOURCE_DIR}
)

target_link_libraries(main
Expand Down
7 changes: 4 additions & 3 deletions firmware/Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -8,16 +8,17 @@ GENERATOR = -G"Unix Makefiles"

COMPILE_COMMANDS_DEST = $(BUILD)/compile_commands.json

build: FORCE
build: config
cmake --build $(BUILD_DIR)

config: FORCE
cmake -B $(BUILD_DIR) -S. $(GENERATOR) -DPROJECT=$(PROJECT) -DPLATFORM=$(PLATFORM) $(COMPILE_COMMANDS_FLAGS)

@echo Copying compile_commands.json to $(BUILD) for clangd.
cp $(BUILD_DIR)/compile_commands.json $(COMPILE_COMMANDS_DEST)
@# Ensure the .clangd file exists
touch .clangd

cmake --build $(BUILD_DIR)

clean: FORCE
rm -rf $(BUILD_DIR)
rm -f $(COMPILE_COMMANDS_DEST)
Expand Down
3 changes: 0 additions & 3 deletions firmware/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -42,9 +42,6 @@ The following dependecies must be installed __and added to your PATH variable.__
* On windows, I had to use the following configuration to help __clangd__ find system header files.

```yaml
If:
PathMatch: .*/windows/.*

CompileFlags:
Add: --target=x86_64-w64-mingw64
```
Expand Down
2 changes: 0 additions & 2 deletions firmware/projects/DemoMapper/platforms/windows/CMakeLists.txt
Original file line number Diff line number Diff line change
@@ -1,5 +1,3 @@
add_library(bindings)

target_sources(bindings
PRIVATE
bindings.cc
Expand Down
Original file line number Diff line number Diff line change
@@ -1,8 +1,6 @@
# Blake Freer
# January 8, 2024

add_library(bindings)

target_sources(bindings
PUBLIC
bindings.cc
Expand Down
Original file line number Diff line number Diff line change
@@ -1,5 +1,3 @@
add_library(bindings)

target_sources(bindings
PRIVATE
bindings.cc
Expand Down
Original file line number Diff line number Diff line change
@@ -1,7 +1,6 @@
# Blake Freer
# January 8, 2024

add_library(bindings)
add_library(os)

target_sources(bindings
Expand Down
Original file line number Diff line number Diff line change
@@ -1,8 +1,6 @@
# Blake Freer
# January 8, 2024

add_library(bindings)

target_sources(bindings
PUBLIC
bindings.cc
Expand Down
Original file line number Diff line number Diff line change
@@ -1,5 +1,3 @@
add_library(bindings)

target_sources(bindings
PRIVATE
bindings.cc
Expand Down
2 changes: 0 additions & 2 deletions firmware/projects/TMS/platforms/stm32f767/CMakeLists.txt
Original file line number Diff line number Diff line change
@@ -1,8 +1,6 @@
# Blake Freer
# January 8, 2024

add_library(bindings)

target_sources(bindings
PUBLIC
bindings.cc
Expand Down
2 changes: 0 additions & 2 deletions firmware/projects/TMS/platforms/windows/CMakeLists.txt
Original file line number Diff line number Diff line change
@@ -1,5 +1,3 @@
add_library(bindings)

target_sources(bindings
PRIVATE
bindings.cc
Expand Down

0 comments on commit 6e2a181

Please sign in to comment.