diff --git a/3d-viewer/3d_cache/sg/CMakeLists.txt b/3d-viewer/3d_cache/sg/CMakeLists.txt index 0899a1925b..0f111a7a8f 100644 --- a/3d-viewer/3d_cache/sg/CMakeLists.txt +++ b/3d-viewer/3d_cache/sg/CMakeLists.txt @@ -91,7 +91,7 @@ endif() unset( S3DSG_VERSION_FILE CACHE ) # Define a flag to expose the appropriate EXPORT macro at build time -target_compile_definitions( kicad_3dsg PRIVATE -DCOMPILE_SGLIB ) +target_compile_definitions( kicad_3dsg PRIVATE COMPILE_SGLIB ) target_link_libraries( kicad_3dsg ${wxWidgets_LIBRARIES} ) @@ -108,4 +108,4 @@ install( TARGETS if( KICAD_WIN32_INSTALL_PDBS ) # Get the PDBs to copy over for MSVC install(FILES $ DESTINATION ${KICAD_BIN}) -endif() \ No newline at end of file +endif() diff --git a/CMakeLists.txt b/CMakeLists.txt index 97b8ae3f21..87fc0f049c 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -53,6 +53,15 @@ set( CMAKE_EXPORT_COMPILE_COMMANDS ON ) set( KICAD_CMAKE_MODULE_PATH "${PROJECT_SOURCE_DIR}/cmake" ) set( CMAKE_MODULE_PATH "${KICAD_CMAKE_MODULE_PATH}" ) + +# Create a flag to identify the non-Apple unix systems +if( UNIX AND NOT APPLE ) + set( UNIX_NOT_APPLE ON ) +else() + set( UNIX_NOT_APPLE OFF ) +endif() + + # # KiCad build options should be added below. # @@ -175,6 +184,13 @@ cmake_dependent_option( KICAD_WIN32_BUILD_PARALLEL_CL_MP OFF "WIN32" OFF ) +# Advanced option to make link maps (only available on linux) +cmake_dependent_option( KICAD_MAKE_LINK_MAPS + "Create link maps for artifacts" + ON "UNIX_NOT_APPLE" + OFF ) +mark_as_advanced( KICAD_MAKE_LINK_MAPS ) + #################################### # Debugging/profiling #################################### @@ -967,17 +983,6 @@ add_subdirectory( doxygen ) configure_file( ${PROJECT_SOURCE_DIR}/cmake/config.h.cmake ${CMAKE_BINARY_DIR}/config.h ) -### -# Generate Map file -### -if( KICAD_MAKE_LINK_MAPS ) - # Currently only works on linux/gcc - if( UNIX AND NOT APPLE ) - set( MAKE_LINK_MAPS true ) - else() - set( MAKE_LINK_MAPS false ) - endif() -endif() #================================================ # "make uninstall" rules diff --git a/cvpcb/CMakeLists.txt b/cvpcb/CMakeLists.txt index 14c9e3da4d..202264d883 100644 --- a/cvpcb/CMakeLists.txt +++ b/cvpcb/CMakeLists.txt @@ -94,10 +94,9 @@ set_source_files_properties( cvpcb.cpp PROPERTIES COMPILE_DEFINITIONS "BUILD_KIWAY_DLL;COMPILING_DLL" ) -if( MAKE_LINK_MAPS ) - set_target_properties( cvpcb_kiface PROPERTIES - LINK_FLAGS "-Wl,-cref,-Map=_cvpcb.kiface.map" ) -endif() +target_link_options( cvpcb_kiface PRIVATE + $<$:-Wl,-cref,-Map=_cvpcb.kiface.map> + ) # these 2 binaries are a matched set, keep them together: if( APPLE ) diff --git a/eeschema/CMakeLists.txt b/eeschema/CMakeLists.txt index 8b343f1a2b..04a70ee6f3 100644 --- a/eeschema/CMakeLists.txt +++ b/eeschema/CMakeLists.txt @@ -525,15 +525,13 @@ set_source_files_properties( eeschema.cpp PROPERTIES # if building eeschema, then also build eeschema_kiface if out of date. add_dependencies( eeschema eeschema_kiface ) -if( MAKE_LINK_MAPS ) - # generate link map with cross reference - set_target_properties( eeschema_kiface PROPERTIES - LINK_FLAGS "-Wl,-cref,-Map=${KIFACE_PREFIX}eeschema${KIFACE_SUFFIX}.map" - ) - set_target_properties( eeschema PROPERTIES - LINK_FLAGS "-Wl,-cref,-Map=eeschema.map" - ) -endif() +# Generate link map with cross reference +target_link_options( eeschema_kiface PRIVATE + $<$:-Wl,-cref,-Map=${KIFACE_PREFIX}eeschema${KIFACE_SUFFIX}.map> + ) +target_link_options( eeschema PRIVATE + $<$:-Wl,-cref,-Map=eeschema.map> + ) # these 2 binaries are a matched set, keep them together: if( APPLE ) diff --git a/gerbview/CMakeLists.txt b/gerbview/CMakeLists.txt index f276fd3f60..f42b163bd8 100644 --- a/gerbview/CMakeLists.txt +++ b/gerbview/CMakeLists.txt @@ -120,11 +120,9 @@ target_include_directories( gerbview PRIVATE $ ) -if( MAKE_LINK_MAPS ) - set_target_properties( gerbview PROPERTIES - LINK_FLAGS "-Wl,-cref,-Map=gerbview.map" ) -endif() - +target_link_options( gerbview PRIVATE + $<$:-Wl,-cref,-Map=gerbview.map> + ) # The objects for the main gerbview program add_library( gerbview_kiface_objects OBJECT @@ -164,10 +162,9 @@ set_source_files_properties( gerbview.cpp PROPERTIES COMPILE_DEFINITIONS "BUILD_KIWAY_DLL;COMPILING_DLL" ) -if( MAKE_LINK_MAPS ) - set_target_properties( gerbview_kiface PROPERTIES - LINK_FLAGS "-Wl,-cref,-Map=_gerbview.kiface.map" ) -endif() +target_link_options( gerbview_kiface PRIVATE + $<$:-Wl,-cref,-Map=_gerbview.kiface.map> + ) # if building gerbview, then also build gerbview_kiface if out of date. add_dependencies( gerbview gerbview_kiface ) diff --git a/pagelayout_editor/CMakeLists.txt b/pagelayout_editor/CMakeLists.txt index 090ac64db9..1b4fe6f3c9 100644 --- a/pagelayout_editor/CMakeLists.txt +++ b/pagelayout_editor/CMakeLists.txt @@ -88,10 +88,9 @@ target_link_libraries( pl_editor ${wxWidgets_LIBRARIES} ) -if( MAKE_LINK_MAPS ) - set_target_properties( pl_editor PROPERTIES - LINK_FLAGS "-Wl,-cref,-Map=pl_editor.map" ) -endif() +target_link_options( pl_editor PRIVATE + $<$:-Wl,-cref,-Map=pl_editor.map> + ) # the main pl_editor program, in DSO form. add_library( pl_editor_kiface MODULE @@ -120,10 +119,9 @@ set_source_files_properties( pl_editor.cpp PROPERTIES COMPILE_DEFINITIONS "BUILD_KIWAY_DLL;COMPILING_DLL" ) -if( MAKE_LINK_MAPS ) - set_target_properties( pl_editor_kiface PROPERTIES - LINK_FLAGS "-Wl,-cref,-Map=_pl_editor.kiface.map" ) -endif() +target_link_options( pl_editor_kiface PRIVATE + $<$:-Wl,-cref,-Map=_pl_editor.kiface.map> + ) # if building pl_editor, then also build pl_editor_kiface if out of date. add_dependencies( pl_editor pl_editor_kiface ) diff --git a/pcb_calculator/CMakeLists.txt b/pcb_calculator/CMakeLists.txt index e943c3e972..11dddae961 100644 --- a/pcb_calculator/CMakeLists.txt +++ b/pcb_calculator/CMakeLists.txt @@ -92,10 +92,9 @@ target_link_libraries( pcb_calculator ${wxWidgets_LIBRARIES} ) -if( MAKE_LINK_MAPS ) - set_target_properties( pcb_calculator PROPERTIES - LINK_FLAGS "-Wl,-cref,-Map=pcb_calculator.map" ) -endif() +target_link_options( pcb_calculator PRIVATE + $<$:-Wl,-cref,-Map=pcb_calculator.map> + ) # the main pcb_calculator program, in DSO form. add_library( pcb_calculator_kiface MODULE @@ -118,10 +117,9 @@ set_source_files_properties( pcb_calculator.cpp PROPERTIES COMPILE_DEFINITIONS "BUILD_KIWAY_DLL;COMPILING_DLL" ) -if( MAKE_LINK_MAPS ) - set_target_properties( pcb_calculator_kiface PROPERTIES - LINK_FLAGS "-Wl,-cref,-Map=_pcb_calculator.kiface.map" ) -endif() +target_link_options( pcb_calculator_kiface PRIVATE + $<$:-Wl,-cref,-Map=_pcb_calculator.kiface.map> + ) # if building pcb_calculator, then also build pcb_calculator_kiface if out of date. add_dependencies( pcb_calculator pcb_calculator_kiface ) diff --git a/pcbnew/CMakeLists.txt b/pcbnew/CMakeLists.txt index 67933f7fc5..46bbc3ff62 100644 --- a/pcbnew/CMakeLists.txt +++ b/pcbnew/CMakeLists.txt @@ -1,13 +1,3 @@ - -if( UNIX AND NOT APPLE ) - # Setting this ON slows down linking and is a advanced (=hidden) developer option for - # linux, not a user option. - option( PCBNEW_LINK_MAPS - "Developer: create linker map files for pcbnew binaries, not typical for Debug builds" - ) - mark_as_advanced( PCBNEW_LINK_MAPS ) -endif() - add_compile_definitions( PCBNEW ) add_subdirectory(connectivity) @@ -613,10 +603,9 @@ target_link_libraries( pcbnew ${wxWidgets_LIBRARIES} ) -if( PCBNEW_LINK_MAPS ) - set_target_properties( pcbnew PROPERTIES - LINK_FLAGS "-Wl,-cref,-Map=pcbnew.map" ) -endif() +target_link_options( pcbnew PRIVATE + $<$:-Wl,-cref,-Map=pcbnew.map> + ) # the main pcbnew program, in DSO form. add_library( pcbnew_kiface_objects OBJECT @@ -707,14 +696,9 @@ set_source_files_properties( pcbnew.cpp PROPERTIES COMPILE_DEFINITIONS "BUILD_KIWAY_DLL;COMPILING_DLL" ) -if( PCBNEW_LINK_MAPS ) - set_target_properties( pcbnew_kiface PROPERTIES - LINK_FLAGS "-Wl,-cref,-Map=_pcbnew.kiface.map" - ) - set_target_properties( pcbnew PROPERTIES - LINK_FLAGS "-Wl,-cref,-Map=pcbnew.map" - ) -endif() +target_link_options( pcbnew_kiface PRIVATE + $<$:-Wl,-cref,-Map=_pcbnew.kiface.map> + ) # if building pcbnew, then also build pcbnew_kiface if out of date. add_dependencies( pcbnew pcbnew_kiface ) diff --git a/scripting/CMakeLists.txt b/scripting/CMakeLists.txt index 3c3ddc9040..02760e9344 100644 --- a/scripting/CMakeLists.txt +++ b/scripting/CMakeLists.txt @@ -61,10 +61,9 @@ set_target_properties( scripting_kiface PROPERTIES SUFFIX ${KIFACE_SUFFIX} ) -if( MAKE_LINK_MAPS ) - set_target_properties( scripting_kiface PROPERTIES - LINK_FLAGS "-Wl,-cref,-Map=_scripting.kiface.map" ) -endif() +target_link_options( scripting_kiface PRIVATE + $<$:-Wl,-cref,-Map=_scripting.kiface.map> + ) if( APPLE ) set_target_properties( scripting_kiface PROPERTIES