Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Rearchitected the chip folder structure #46

Open
wants to merge 1 commit into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
15 changes: 0 additions & 15 deletions 3rdparty/cmake.gtest.txt.in

This file was deleted.

1 change: 0 additions & 1 deletion CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,6 @@ project(queso CXX)

add_subdirectory(3rdparty)
add_subdirectory(chips)

nasamuffin marked this conversation as resolved.
Show resolved Hide resolved
add_subdirectory(tests)

### Use build/out for install directory
Expand Down
26 changes: 18 additions & 8 deletions chips/CMakeLists.txt
Original file line number Diff line number Diff line change
@@ -1,10 +1,20 @@
project(count CXX)
option(AUTO_ENABLE_CHIPS "Automatically build all chips found in project" OFF)

set(SOURCES
count.cpp
)
set(ENABLED_CHIPS "" CACHE STRING "Enable each listed chip rather than auto-detect")
Copy link
Owner

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

should you only set this ifndef AUTO_ENABLE_CHIPS?

Copy link
Author

@ghost ghost Nov 15, 2019

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This is tricky, it would require a FORCE over the user's selection so I'm inclined to think it's better this way.

if (all)
glob cmake files
else if (some)
check some exists
else
none enabled

set(found_chips "")
Copy link
Owner

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

similarly, should you only enable this ifdef AUTO_ENABLE_CHIPS?


add_library(${PROJECT_NAME} SHARED ${SOURCES})
spdlog_enable_warnings(${PROJECT_NAME})
target_link_libraries(${PROJECT_NAME} PRIVATE spdlog::spdlog)
target_compile_features(${PROJECT_NAME} PUBLIC cxx_std_17)
if(${AUTO_ENABLE_CHIPS})
file(GLOB_RECURSE found_chips "*chip.cmake")
else()
foreach(_chip ${ENABLED_CHIPS})
if(EXISTS "${CMAKE_CURRENT_SOURCE_DIR}/${_chip}/chip.cmake")
Copy link
Owner

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Doesn't this fail silently if the chip is in the enable list but not found?

Copy link
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

There's a line about which chips were turned on. I think when someone says -DENABLED_CHIPS="blah blah" and then don't see one of the chips in the output that's a good indicator.

list(APPEND found_chips "${CMAKE_CURRENT_SOURCE_DIR}/${_chip}/chip.cmake")
endif()
endforeach(_chip)
endif()

set(CMAKE_INCLUDE_CURRENT_DIR ON)
foreach(_chip ${found_chips})
message("Chip enabled: ${_chip}")
include(${_chip})
endforeach(_chip)
10 changes: 10 additions & 0 deletions chips/example/chip.cmake
Original file line number Diff line number Diff line change
@@ -0,0 +1,10 @@
project(count_example CXX)

set(SOURCES
example/count_example.cpp
)

add_library(${PROJECT_NAME} SHARED ${SOURCES})
spdlog_enable_warnings(${PROJECT_NAME})
target_link_libraries(${PROJECT_NAME} PRIVATE spdlog::spdlog)
target_compile_features(${PROJECT_NAME} PUBLIC cxx_std_17)
File renamed without changes.