Skip to content

Commit

Permalink
[#154] Use separate include directories for each component
Browse files Browse the repository at this point in the history
This also fixed a bug where components were not actually usable
  • Loading branch information
DavidZemon committed Feb 28, 2019
1 parent 56796b4 commit 75eb727
Show file tree
Hide file tree
Showing 11 changed files with 39 additions and 21 deletions.
2 changes: 1 addition & 1 deletion CMakeModules
18 changes: 15 additions & 3 deletions PropWareInstall.cmake
Original file line number Diff line number Diff line change
Expand Up @@ -22,17 +22,29 @@ if (PACKAGE_OSX)
COMPONENT macosx_cmakemodules)
endif ()

# PropWare & libpropeller includes
# PropWare includes
install(DIRECTORY
"${PROJECT_SOURCE_DIR}/PropWare"
DESTINATION share/PropWare/include/PropWare
COMPONENT propware
FILES_MATCHING PATTERN *.h)

# libpropeller includes
install(DIRECTORY
"${PROJECT_SOURCE_DIR}/libpropeller/libpropeller"
"${PROJECT_SOURCE_DIR}/libArduino/libPropelleruino/"
DESTINATION share/PropWare/include/c++
DESTINATION share/PropWare/include/Libpropeller
COMPONENT propware
FILES_MATCHING PATTERN *.h
PATTERN libpropeller/libpropeller/compile_tools EXCLUDE
PATTERN libpropeller/libpropeller/unity_tools/asmsrc EXCLUDE)

# libPropelleruino includes
install(DIRECTORY
"${PROJECT_SOURCE_DIR}/libArduino/libPropelleruino/"
DESTINATION share/PropWare/include/LibPropelleruino
COMPONENT propware
FILES_MATCHING PATTERN *.h)

# Version file
file(WRITE "${PROJECT_BINARY_DIR}/version.txt" "${PROJECT_VERSION}")
install(FILES
Expand Down
17 changes: 9 additions & 8 deletions PropWareSources.cmake
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
function(create_pw_lib)
set(options C_ONLY)
set(options )
set(oneValueArgs LIB_NAME MODEL)
set(multiValueArgs EXTRA_INCLUDE_DIRS SOURCES)
cmake_parse_arguments(ARGS "${options}" "${oneValueArgs}" "${multiValueArgs}" ${ARGN})
Expand All @@ -12,17 +12,18 @@ function(create_pw_lib)
set_compile_flags(${TARGET} ${ARGS_MODEL})
if (NOT LIB_NAME STREQUAL "PropWare")
target_compile_options(${TARGET} PRIVATE -w)
endif ()
if (ARGS_C_ONLY)
set(SYSTEM_ARG SYSTEM)
target_include_directories(${TARGET} SYSTEM PUBLIC $<INSTALL_INTERFACE:share/PropWare/include>)
else ()
target_include_directories(${TARGET} PUBLIC $<INSTALL_INTERFACE:share/PropWare/include/c++>)
if (LIB_NAME STREQUAL "Simple")
set(SYSTEM_ARG SYSTEM)
endif ()
endif ()
foreach(d IN LISTS ARGS_EXTRA_INCLUDE_DIRS)
list(APPEND BUILD_INTERFACE_DIRS $<BUILD_INTERFACE:${d}>)
endforeach()
target_include_directories(${TARGET} ${SYSTEM_ARG} PUBLIC ${BUILD_INTERFACE_DIRS})
target_include_directories(${TARGET} ${SYSTEM_ARG}
PUBLIC
${BUILD_INTERFACE_DIRS}
$<INSTALL_INTERFACE:share/PropWare/include/${ARGS_LIB_NAME}>
)
set_linker(${TARGET})
set_target_properties(${TARGET} PROPERTIES OUTPUT_NAME ${ARGS_LIB_NAME})
install(TARGETS ${TARGET}
Expand Down
9 changes: 7 additions & 2 deletions external_libs/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -56,13 +56,18 @@ foreach(project_file IN LISTS SIMPLE_IDE_PROJECT_FILES)
endforeach()

install(FILES ${SIMPLE_HEADERS}
DESTINATION share/PropWare/include
DESTINATION share/PropWare/include/Simple
COMPONENT propware)
####################################################################

####################################################################
add_library(ArduinoJson INTERFACE)
target_include_directories(ArduinoJson INTERFACE
$<BUILD_INTERFACE:${PROJECT_SOURCE_DIR}/ArduinoJson/src>
$<INSTALL_INTERFACE:share/PropWare/include/ArduinoJson>
)
install(DIRECTORY ${PROJECT_SOURCE_DIR}/ArduinoJson/src/
DESTINATION share/PropWare/include/c++
DESTINATION share/PropWare/include/ArduinoJson
COMPONENT propware)
####################################################################

Expand Down
2 changes: 1 addition & 1 deletion external_libs/cmm/CMakeLists.txt
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
set(MODEL cmm)
parse_simpleide_project_files(Simple_${MODEL} "${SIMPLE_IDE_PROJECT_FILES}")
create_pw_lib(LIB_NAME Simple MODEL ${MODEL} C_ONLY
create_pw_lib(LIB_NAME Simple MODEL ${MODEL}
EXTRA_INCLUDE_DIRS ${SIMPLE_INCLUDE_DIRS}
)
create_pw_lib(LIB_NAME Libpropeller MODEL ${MODEL}
Expand Down
2 changes: 1 addition & 1 deletion external_libs/cog/CMakeLists.txt
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
set(MODEL cog)
parse_simpleide_project_files(Simple_${MODEL} "${SIMPLE_IDE_PROJECT_FILES}")
create_pw_lib(LIB_NAME Simple MODEL ${MODEL} C_ONLY
create_pw_lib(LIB_NAME Simple MODEL ${MODEL}
EXTRA_INCLUDE_DIRS ${SIMPLE_INCLUDE_DIRS}
)
create_pw_lib(LIB_NAME Libpropeller MODEL ${MODEL}
Expand Down
2 changes: 1 addition & 1 deletion external_libs/lmm/CMakeLists.txt
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
set(MODEL lmm)
parse_simpleide_project_files(Simple_${MODEL} "${SIMPLE_IDE_PROJECT_FILES}")
create_pw_lib(LIB_NAME Simple MODEL ${MODEL} C_ONLY
create_pw_lib(LIB_NAME Simple MODEL ${MODEL}
EXTRA_INCLUDE_DIRS ${SIMPLE_INCLUDE_DIRS}
)
create_pw_lib(LIB_NAME Libpropeller MODEL ${MODEL}
Expand Down
2 changes: 1 addition & 1 deletion external_libs/xmm-single/CMakeLists.txt
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
set(MODEL xmm-single)
parse_simpleide_project_files(Simple_${MODEL} "${SIMPLE_IDE_PROJECT_FILES}")
create_pw_lib(LIB_NAME Simple MODEL ${MODEL} C_ONLY
create_pw_lib(LIB_NAME Simple MODEL ${MODEL}
EXTRA_INCLUDE_DIRS ${SIMPLE_INCLUDE_DIRS}
)
create_pw_lib(LIB_NAME Libpropeller MODEL ${MODEL}
Expand Down
2 changes: 1 addition & 1 deletion external_libs/xmm-split/CMakeLists.txt
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
set(MODEL xmm-split)
parse_simpleide_project_files(Simple_${MODEL} "${SIMPLE_IDE_PROJECT_FILES}")
create_pw_lib(LIB_NAME Simple MODEL ${MODEL} C_ONLY
create_pw_lib(LIB_NAME Simple MODEL ${MODEL}
EXTRA_INCLUDE_DIRS ${SIMPLE_INCLUDE_DIRS}
)
create_pw_lib(LIB_NAME Libpropeller MODEL ${MODEL}
Expand Down
2 changes: 1 addition & 1 deletion external_libs/xmmc/CMakeLists.txt
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
set(MODEL xmmc)
parse_simpleide_project_files(Simple_${MODEL} "${SIMPLE_IDE_PROJECT_FILES}")
create_pw_lib(LIB_NAME Simple MODEL ${MODEL} C_ONLY
create_pw_lib(LIB_NAME Simple MODEL ${MODEL}
EXTRA_INCLUDE_DIRS ${SIMPLE_INCLUDE_DIRS}
)
create_pw_lib(LIB_NAME Libpropeller MODEL ${MODEL}
Expand Down
2 changes: 1 addition & 1 deletion test/PropWare/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -30,5 +30,5 @@ set_tests_properties(
PROPERTIES LABELS hardware-independent)

install(FILES PropWareTests.h
DESTINATION share/PropWare/include/c++/PropWare
DESTINATION share/PropWare/include/PropWare/PropWare
COMPONENT propware)

0 comments on commit 75eb727

Please sign in to comment.