kicad-source/kicad/CMakeLists.txt

308 lines
11 KiB
CMake
Raw Normal View History

# 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_definitions( -DKICAD )
2022-01-02 10:14:15 -08:00
add_subdirectory( pcm )
include_directories( BEFORE ${INC_BEFORE} )
include_directories(
${CMAKE_SOURCE_DIR}/pcbnew
${CMAKE_SOURCE_DIR}/eeschema
2022-01-02 10:14:15 -08:00
${CMAKE_SOURCE_DIR}/kicad/pcm
${INC_AFTER}
)
set( KICAD_SRCS
dialogs/dialog_template_selector_base.cpp
dialogs/dialog_template_selector.cpp
dialogs/panel_kicad_launcher_base.cpp
dialogs/panel_kicad_launcher.cpp
files-io.cpp
import_proj.cpp
import_project.cpp
kicad_manager_frame.cpp
menubar.cpp
project_template.cpp
project_tree_pane.cpp
project_tree.cpp
project_tree_item.cpp
tools/kicad_manager_actions.cpp
tools/kicad_manager_control.cpp
)
set( KICAD_CLI_SRCS
cli/command.cpp
2022-10-27 21:57:12 -04:00
cli/command_export_pcb_base.cpp
cli/command_export_pcb_drill.cpp
2022-10-27 21:57:12 -04:00
cli/command_export_pcb_dxf.cpp
cli/command_export_pcb_gerber.cpp
cli/command_export_pcb_gerbers.cpp
cli/command_export_pcb_pdf.cpp
cli/command_export_pcb_pos.cpp
2022-10-27 21:57:12 -04:00
cli/command_export_pcb_step.cpp
cli/command_export_pcb_svg.cpp
cli/command_fp_export_svg.cpp
2022-11-27 21:27:34 -05:00
cli/command_fp_upgrade.cpp
cli/command_export_sch_pythonbom.cpp
2022-11-09 22:37:47 -05:00
cli/command_export_sch_netlist.cpp
2022-10-26 17:59:33 -04:00
cli/command_export_sch_pdf.cpp
cli/command_export_sch_svg.cpp
cli/command_sym_export_svg.cpp
cli/command_sym_upgrade.cpp
cli/command_version.cpp
)
if( WIN32 )
if( MINGW )
# KICAD_RESOURCES variable is set by the macro.
mingw_resource_compiler( kicad )
else()
set( KICAD_RESOURCES ${CMAKE_SOURCE_DIR}/resources/msw/kicad.rc )
endif()
* KIWAY Milestone A): Make major modules into DLL/DSOs. ! The initial testing of this commit should be done using a Debug build so that all the wxASSERT()s are enabled. Also, be sure and keep enabled the USE_KIWAY_DLLs option. The tree won't likely build without it. Turning it off is senseless anyways. If you want stable code, go back to a prior version, the one tagged with "stable". * Relocate all functionality out of the wxApp derivative into more finely targeted purposes: a) DLL/DSO specific b) PROJECT specific c) EXE or process specific d) configuration file specific data e) configuration file manipulations functions. All of this functionality was blended into an extremely large wxApp derivative and that was incompatible with the desire to support multiple concurrently loaded DLL/DSO's ("KIFACE")s and multiple concurrently open projects. An amazing amount of organization come from simply sorting each bit of functionality into the proper box. * Switch to wxConfigBase from wxConfig everywhere except instantiation. * Add classes KIWAY, KIFACE, KIFACE_I, SEARCH_STACK, PGM_BASE, PGM_KICAD, PGM_SINGLE_TOP, * Remove "Return" prefix on many function names. * Remove obvious comments from CMakeLists.txt files, and from else() and endif()s. * Fix building boost for use in a DSO on linux. * Remove some of the assumptions in the CMakeLists.txt files that windows had to be the host platform when building windows binaries. * Reduce the number of wxStrings being constructed at program load time via static construction. * Pass wxConfigBase* to all SaveSettings() and LoadSettings() functions so that these functions are useful even when the wxConfigBase comes from another source, as is the case in the KICAD_MANAGER_FRAME. * Move the setting of the KIPRJMOD environment variable into class PROJECT, so that it can be moved into a project variable soon, and out of FP_LIB_TABLE. * Add the KIWAY_PLAYER which is associated with a particular PROJECT, and all its child wxFrames and wxDialogs now have a Kiway() member function which returns a KIWAY& that that window tree branch is in support of. This is like wxWindows DNA in that child windows get this member with proper value at time of construction. * Anticipate some of the needs for milestones B) and C) and make code adjustments now in an effort to reduce work in those milestones. * No testing has been done for python scripting, since milestone C) has that being largely reworked and re-thought-out.
2014-03-19 19:42:08 -05:00
endif()
if( APPLE )
set( KICAD_RESOURCES kicad.icns kicad_doc.icns )
set_source_files_properties( "${CMAKE_CURRENT_SOURCE_DIR}/kicad.icns" PROPERTIES
MACOSX_PACKAGE_LOCATION Resources
)
set_source_files_properties( "${CMAKE_CURRENT_SOURCE_DIR}/kicad_doc.icns" PROPERTIES
MACOSX_PACKAGE_LOCATION Resources
)
set( MACOSX_BUNDLE_ICON_FILE kicad.icns )
set( MACOSX_BUNDLE_GUI_IDENTIFIER org.kicad.kicad )
set( MACOSX_BUNDLE_NAME kicad )
endif()
add_executable( kicad WIN32 MACOSX_BUNDLE
kicad.cpp
${KICAD_SRCS}
${KICAD_EXTRA_SRCS}
${KICAD_RESOURCES}
)
2022-10-11 10:20:21 -04:00
add_executable( kicad-cli WIN32
kicad_cli.cpp
${KICAD_CLI_SRCS}
${KICAD_EXTRA_SRCS}
${KICAD_RESOURCES}
)
if( MSVC )
# The cli needs subsystem:console or else we can't link wmain/main
set_target_properties(kicad-cli PROPERTIES COMPILE_DEFINITIONS_DEBUG "_CONSOLE")
set_target_properties(kicad-cli PROPERTIES COMPILE_DEFINITIONS_RELWITHDEBINFO "_CONSOLE")
set_target_properties(kicad-cli PROPERTIES LINK_FLAGS_DEBUG "/SUBSYSTEM:CONSOLE")
set_target_properties(kicad-cli PROPERTIES LINK_FLAGS_RELWITHDEBINFO "/SUBSYSTEM:CONSOLE")
set_target_properties(kicad-cli PROPERTIES LINK_FLAGS_RELEASE "/SUBSYSTEM:CONSOLE")
set_target_properties(kicad-cli PROPERTIES LINK_FLAGS_MINSIZEREL "/SUBSYSTEM:CONSOLE")
endif()
if( UNIX )
# for build directory: create kiface symlinks so kicad (exe) can be run in-situ
add_custom_target( kiface_sym_links
COMMAND ${CMAKE_COMMAND} -E create_symlink "${CMAKE_BINARY_DIR}/eeschema/_eeschema.kiface" "${CMAKE_BINARY_DIR}/kicad/_eeschema.kiface"
COMMAND ${CMAKE_COMMAND} -E create_symlink "${CMAKE_BINARY_DIR}/pcbnew/_pcbnew.kiface" "${CMAKE_BINARY_DIR}/kicad/_pcbnew.kiface"
COMMAND ${CMAKE_COMMAND} -E create_symlink "${CMAKE_BINARY_DIR}/cvpcb/_cvpcb.kiface" "${CMAKE_BINARY_DIR}/kicad/_cvpcb.kiface"
COMMENT "Making <build-dir>/kicad/<kiface.symlinks>"
)
endif()
if( APPLE )
set_target_properties( kicad PROPERTIES
MACOSX_BUNDLE_INFO_PLIST ${PROJECT_BINARY_DIR}/kicad/Info.plist
)
target_link_libraries( kicad
nlohmann_json
common
${wxWidgets_LIBRARIES}
)
set_target_properties( kicad-cli PROPERTIES
2022-10-11 15:49:55 -04:00
RUNTIME_OUTPUT_DIRECTORY ${OSX_BUNDLE_BUILD_BIN_DIR}
)
target_link_libraries( kicad-cli
nlohmann_json
common
${wxWidgets_LIBRARIES}
)
else()
target_link_libraries( kicad
nlohmann_json
common
gal
common #repeated due to a circular dependency between gal and common
${wxWidgets_LIBRARIES}
)
target_link_libraries( kicad-cli
nlohmann_json
common
gal
common #repeated due to a circular dependency between gal and common
${wxWidgets_LIBRARIES}
)
endif()
2022-01-02 10:14:15 -08:00
target_link_libraries( kicad pcm )
target_link_libraries( kicad-cli pcm )
2020-10-26 03:54:36 -07:00
target_include_directories( kicad PRIVATE
$<TARGET_PROPERTY:thread-pool,INTERFACE_INCLUDE_DIRECTORIES>
)
target_include_directories( kicad-cli PRIVATE
$<TARGET_PROPERTY:thread-pool,INTERFACE_INCLUDE_DIRECTORIES>
)
2022-10-12 08:31:56 -04:00
install( TARGETS kicad
DESTINATION ${KICAD_BIN}
COMPONENT binary
)
2021-07-14 23:31:56 -04:00
if( NOT APPLE )
install( TARGETS kicad-cli
DESTINATION ${KICAD_BIN}
COMPONENT binary
)
endif()
2021-07-14 23:31:56 -04:00
if( KICAD_WIN32_INSTALL_PDBS )
# Get the PDBs to copy over for MSVC
install(FILES $<TARGET_PDB_FILE:kicad> DESTINATION ${KICAD_BIN})
endif()
if( APPLE )
# "install( CODE ... )" will launch its own CMake, so no variables from
# this CMake instance are accessible... use helper to transfer
2021-03-08 06:54:22 -08:00
set( SCRIPTING_HELPER "1" )
2021-07-14 23:31:56 -04:00
if( KICAD_SPICE )
set( SPICE_HELPER "1" )
else()
set( SPICE_HELPER "0" )
endif()
if( PYTHON_FRAMEWORK )
set( PYTHON_FRAMEWORK_HELPER "1" )
else()
set( PYTHON_FRAMEWORK_HELPER "0" )
endif()
if( MACOS_EXTRA_BUNDLE_FIX_DIRS )
set( BUNDLE_FIX_DIRS ${BUNDLE_FIX_DIRS} ${MACOS_EXTRA_BUNDLE_FIX_DIRS} ) # TODO: where should we document MACOS_EXTRA_BUNDLE_FIX_DIRS?
endif()
set( BUNDLE_FIX_DIRS ${BUNDLE_FIX_DIRS} ${OCC_LIBRARY_DIR} )
# make main bundle relocatable
install( CODE "
set( BUNDLE_FIX_DIRS ${BUNDLE_FIX_DIRS} ) # pull in the variable from above, so we can append if needed
# find all kicad libs and modules
file( GLOB PLUGINS_KIFACE ${OSX_BUNDLE_INSTALL_KIFACE_DIR}/*.kiface )
file( GLOB_RECURSE PLUGINS_SO ${OSX_BUNDLE_INSTALL_PLUGIN_DIR}/*.so )
file( GLOB_RECURSE PLUGINS_3D ${OSX_BUNDLE_INSTALL_PLUGIN_DIR}/3d/*.dylib )
set( BUNDLE_FIX_LIBS \${PLUGINS_KIFACE} \${PLUGINS_SO} \${PLUGINS_3D} )
# Find ngspice if it is being packaged
if( ${SPICE_HELPER} )
file( GLOB_RECURSE PLUGINS_NGSPICE ${OSX_BUNDLE_INSTALL_PLUGIN_DIR}/sim/*.dylib )
set( BUNDLE_FIX_LIBS \${BUNDLE_FIX_LIBS} \${PLUGINS_NGSPICE} )
endif()
# Find python if it is requested
if( ${SCRIPTING_HELPER} )
# file( GLOB WXPYTHON_DIR RELATIVE ${OSX_BUNDLE_BUILD_DIR}/${OSX_BUNDLE_PYTHON_SITE_PACKAGES_DIR} ${OSX_BUNDLE_INSTALL_PYTHON_SITE_PACKAGES_DIR}/wx-?.?-osx_cocoa )
# file( GLOB PYTHON_SCRIPTING_SO ${OSX_BUNDLE_INSTALL_PYTHON_SITE_PACKAGES_DIR}/*.so )
# set( BUNDLE_FIX_LIBS \${BUNDLE_FIX_LIBS} \${PYTHON_SCRIPTING_SO} )
# file( GLOB PYTHON_SCRIPTING_SO ${OSX_BUNDLE_INSTALL_PYTHON_SITE_PACKAGES_DIR}/\${WXPYTHON_DIR}/wx/*.so )
# set( BUNDLE_FIX_LIBS \${BUNDLE_FIX_LIBS} \${PYTHON_SCRIPTING_SO} )
endif()
# override default embedded path settings
${OSX_BUNDLE_OVERRIDE_PATHS}
# do all the work
if ( ${PYTHON_FRAMEWORK_HELPER} )
# This idea here is to repair anything that fixup_bundle doesn't handle
# properly for our setup with both Python.framework *and* symlinked subapps
# that's needed for *running* here
# Anything that's needed strictly for packaging and making redistributable
# macOS builds can be defined in kicad-mac-builder
# Of course, making it all work right here would be even slicker,
# but if wishes were horses...
# It would be awesome if we find a better solution (or BundleUtilities works for our corner case better)
execute_process( COMMAND cp -RP ${PYTHON_FRAMEWORK} ${OSX_BUNDLE_INSTALL_LIB_DIR}/)
# We're using cp -RP because CMake's COPY_RESOLVED_BUNDLE... and COPY_DIRECTORY don't handle symlinks correctly
# Add any .so files in the site-packages directory to the list of things to fixup during fixup_bundle
2021-04-15 10:46:44 -05:00
file( GLOB_RECURSE PYTHON_SITE_PACKAGES_LIBS ${OSX_BUNDLE_INSTALL_PYTHON_SITE_PACKAGES_DIR}/*.so )
set( BUNDLE_FIX_LIBS \${BUNDLE_FIX_LIBS} \${PYTHON_SITE_PACKAGES_LIBS} )
fixup_bundle( ${OSX_BUNDLE_INSTALL_BIN_DIR}/kicad
\"\${BUNDLE_FIX_LIBS}\"
2022-04-20 07:17:06 -07:00
\"\${BUNDLE_FIX_DIRS};${PYTHON_FRAMEWORK}\"
IGNORE_ITEM \"Python;python;pythonw;python3;pythonw3;python3.8;pythonw3.8;python3.9;python3.9-intel64\"
)
# BundleUtilities clobbers the rpaths and install_names that we carefully setup in Python.framework, even if
# we mark Python things as IGNORE_ITEMs. We'll refix them later.
else()
fixup_bundle( ${OSX_BUNDLE_INSTALL_BIN_DIR}/kicad
\"\${BUNDLE_FIX_LIBS}\"
\"\${BUNDLE_FIX_DIRS}\"
)
endif()
if( ${SPICE_HELPER} )
execute_process( COMMAND install_name_tool -id @executable_path/../PlugIns/sim/libngspice.0.dylib libngspice.0.dylib
WORKING_DIRECTORY ${OSX_BUNDLE_INSTALL_PLUGIN_DIR}/sim )
endif()
" COMPONENT Runtime
)
# move all individual app bundles into main bundle
install( CODE "
# helper function to move a bundle into main bundle
function( move_to_main_bundle bundle_name symlink_name )
message( STATUS \"Moving \${bundle_name} into main bundle...\" )
file( MAKE_DIRECTORY ${OSX_BUNDLE_INSTALL_DIR}/${OSX_BUNDLE_APP_DIR} )
file( REMOVE_RECURSE ${KICAD_BIN}/\${bundle_name}/${OSX_BUNDLE_LIB_DIR} )
file( RENAME ${KICAD_BIN}/\${bundle_name} ${OSX_BUNDLE_INSTALL_DIR}/${OSX_BUNDLE_APP_DIR}/\${bundle_name} )
execute_process( COMMAND ${CMAKE_COMMAND} -E create_symlink \"../../../Frameworks\" \"Frameworks\"
WORKING_DIRECTORY ${OSX_BUNDLE_INSTALL_DIR}/${OSX_BUNDLE_APP_DIR}/\${bundle_name}/Contents
)
# create a top-level link pointing inside main bundle
execute_process( COMMAND ${CMAKE_COMMAND} -E create_symlink \"${OSX_BUNDLE_MAIN}/${OSX_BUNDLE_APP_DIR}/\${bundle_name}\" \"\${symlink_name}\"
WORKING_DIRECTORY ${KICAD_BIN}
)
endfunction( move_to_main_bundle )
# move all app bundles
move_to_main_bundle( \"bitmap2component.app\" \"Bitmap2Component.app\" )
move_to_main_bundle( \"eeschema.app\" \"Eeschema.app\" )
move_to_main_bundle( \"gerbview.app\" \"GerbView.app\" )
move_to_main_bundle( \"pcb_calculator.app\" \"PCB Calculator.app\" )
move_to_main_bundle( \"pcbnew.app\" \"Pcbnew.app\" )
move_to_main_bundle( \"pl_editor.app\" \"Page Layout Editor.app\" )
if ( ${PYTHON_FRAMEWORK_HELPER} )
include( ${KICAD_CMAKE_MODULE_PATH}/RefixupMacOS.cmake )
refix_kicad_bundle( ${OSX_BUNDLE_INSTALL_DIR} )
endif( )
" COMPONENT Runtime
)
endif()