Introduce core interface library

This library is meant to move non-EDA items (language extensions,
library extensions, etc.) into the lowest-level of our dependency chain.
This library should never depend on anyother non-thirdparty code in the
kicad codebase.
This commit is contained in:
Ian McInerney 2023-04-05 00:34:46 +01:00
parent b05de51a8d
commit ea62b145ff
18 changed files with 48 additions and 3 deletions

View File

@ -114,6 +114,7 @@ target_link_libraries( 3d-viewer
PRIVATE PRIVATE
gal gal
kimath kimath
core
nlohmann_json nlohmann_json
Boost::headers Boost::headers
${wxWidgets_LIBRARIES} ${wxWidgets_LIBRARIES}

View File

@ -483,6 +483,7 @@ target_link_libraries( common
libcontext libcontext
kimath kimath
kiplatform kiplatform
core
fmt::fmt fmt::fmt
gal gal
scripting scripting
@ -618,6 +619,7 @@ target_link_libraries( pcbcommon PUBLIC
delaunator delaunator
kimath kimath
kiplatform kiplatform
core
threadpool threadpool
) )

View File

@ -483,6 +483,7 @@ target_link_libraries( eeschema_kiface
markdown_lib markdown_lib
scripting scripting
sexpr sexpr
core
Boost::headers Boost::headers
${wxWidgets_LIBRARIES} ${wxWidgets_LIBRARIES}
${NGSPICE_LIBRARY} ${NGSPICE_LIBRARY}

View File

@ -112,6 +112,7 @@ target_link_libraries( gerbview
# There's way too much crap coming in from common yet. # There's way too much crap coming in from common yet.
gal gal
common common
core
nlohmann_json nlohmann_json
${wxWidgets_LIBRARIES} ${wxWidgets_LIBRARIES}
) )
@ -137,6 +138,7 @@ target_link_libraries( gerbview_kiface_objects
PUBLIC PUBLIC
common common
gal gal
core
) )
# the main gerbview program, in DSO form. # the main gerbview program, in DSO form.
@ -153,6 +155,7 @@ target_link_libraries( gerbview_kiface
nlohmann_json nlohmann_json
gal gal
common common
core
gerbview_kiface_objects gerbview_kiface_objects
${wxWidgets_LIBRARIES} ${wxWidgets_LIBRARIES}
) )

View File

@ -118,6 +118,7 @@ if( APPLE )
target_link_libraries( kicad target_link_libraries( kicad
nlohmann_json nlohmann_json
common common
core
${wxWidgets_LIBRARIES} ${wxWidgets_LIBRARIES}
) )
@ -129,6 +130,7 @@ if( APPLE )
nlohmann_json nlohmann_json
common common
${wxWidgets_LIBRARIES} ${wxWidgets_LIBRARIES}
core
) )
else() else()
target_link_libraries( kicad target_link_libraries( kicad
@ -136,6 +138,7 @@ else()
common common
gal gal
common #repeated due to a circular dependency between gal and common common #repeated due to a circular dependency between gal and common
core
${wxWidgets_LIBRARIES} ${wxWidgets_LIBRARIES}
) )
@ -144,6 +147,7 @@ else()
common common
gal gal
common #repeated due to a circular dependency between gal and common common #repeated due to a circular dependency between gal and common
core
${wxWidgets_LIBRARIES} ${wxWidgets_LIBRARIES}
) )
endif() endif()

View File

@ -55,7 +55,10 @@ add_library( pcm_settings STATIC
# This is a circular dependency but it's not a problem for static libs. # This is a circular dependency but it's not a problem for static libs.
# Refactoring this would need separating kicad_settings, settings manager # Refactoring this would need separating kicad_settings, settings manager
# and pgm_base out of common. # and pgm_base out of common.
target_link_libraries( pcm_settings common ) target_link_libraries( pcm_settings
common
core
)
target_include_directories( target_include_directories(
pcm_settings pcm_settings

View File

@ -22,6 +22,7 @@
# #
# Build file for generic re-useable libraries # Build file for generic re-useable libraries
add_subdirectory( core )
add_subdirectory( kimath ) add_subdirectory( kimath )
add_subdirectory( kiplatform ) add_subdirectory( kiplatform )
add_subdirectory( sexpr ) add_subdirectory( sexpr )

18
libs/core/CMakeLists.txt Normal file
View File

@ -0,0 +1,18 @@
# Add all the warnings to the files
if( COMPILER_SUPPORTS_WARNINGS )
set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} ${WARN_FLAGS_CXX}")
set(CMAKE_C_FLAGS "${CMAKE_C_FLAGS} ${WARN_FLAGS_C}")
endif()
add_library( core INTERFACE
# Just a header library right now
)
target_link_libraries( core INTERFACE
${wxWidgets_LIBRARIES}
)
target_include_directories( core INTERFACE
${CMAKE_CURRENT_SOURCE_DIR}/include
)

3
libs/core/Readme.md Normal file
View File

@ -0,0 +1,3 @@
This library contains base non-EDA items and extensions to libraries that are used throughout
the KiCad codebase. This library should never depend on any parts of the KiCad code outside the
thirdparty directory, since this is meant to be the lowest-level library in the dependency chain.

View File

@ -38,6 +38,7 @@ add_library( kimath STATIC
) )
target_link_libraries( kimath target_link_libraries( kimath
core
clipper clipper
clipper2 clipper2
othermath othermath
@ -49,9 +50,13 @@ target_link_libraries( kimath
target_include_directories( kimath PUBLIC target_include_directories( kimath PUBLIC
${PROJECT_BINARY_DIR} ${PROJECT_BINARY_DIR}
${CMAKE_CURRENT_SOURCE_DIR}/include ${CMAKE_CURRENT_SOURCE_DIR}/include
# This include REALLY shouldn't be here, but shape_arc.h grew a dependency on the units somehow
${CMAKE_SOURCE_DIR}/include
) )
target_include_directories( kimath PRIVATE target_include_directories( kimath PRIVATE
${PROJECT_SOURCE_DIR}/include # core/kicad_algo.h is needed for shape_arc # This include REALLY shouldn't be here, but shape_arc grew a dependency on the units somehow
${CMAKE_SOURCE_DIR}/include
${wxWidgets_LIBRARIES} ${wxWidgets_LIBRARIES}
) )

View File

@ -85,6 +85,7 @@ target_link_libraries( pl_editor
# There's way too much crap coming in from common yet. # There's way too much crap coming in from common yet.
gal gal
common common
core
${wxWidgets_LIBRARIES} ${wxWidgets_LIBRARIES}
) )
@ -102,6 +103,7 @@ add_library( pl_editor_kiface MODULE
target_link_libraries( pl_editor_kiface target_link_libraries( pl_editor_kiface
gal gal
common common
core
${wxWidgets_LIBRARIES} ${wxWidgets_LIBRARIES}
) )
set_target_properties( pl_editor_kiface PROPERTIES set_target_properties( pl_editor_kiface PROPERTIES

View File

@ -595,6 +595,7 @@ target_link_libraries( pcbnew
common common
gal gal
scripting scripting
core
nlohmann_json nlohmann_json
rectpack2d rectpack2d
argparse::argparse argparse::argparse
@ -625,6 +626,7 @@ make_lexer(
target_link_libraries( pcbnew_kiface_objects target_link_libraries( pcbnew_kiface_objects
PRIVATE PRIVATE
common common
core
dxflib_qcad dxflib_qcad
nanosvg nanosvg
tinyspline_lib tinyspline_lib
@ -672,6 +674,7 @@ set( PCBNEW_KIFACE_LIBRARIES
common common
gal gal
scripting scripting
core
dxflib_qcad dxflib_qcad
tinyspline_lib tinyspline_lib
idf3 idf3

View File

@ -76,7 +76,6 @@ target_link_libraries( qa_kimath
) )
target_include_directories( qa_kimath PRIVATE target_include_directories( qa_kimath PRIVATE
${CMAKE_SOURCE_DIR}/include # Needed for core/optional.h
${CMAKE_SOURCE_DIR}/qa/mocks/include ${CMAKE_SOURCE_DIR}/qa/mocks/include
${CMAKE_CURRENT_SOURCE_DIR} ${CMAKE_CURRENT_SOURCE_DIR}
) )