You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

53 lines
1.8 KiB

  1. # The libcontext library is only included inside common, so we create it as an
  2. # object library and then add the objects to common.
  3. # Link-time optimization (LTO) on GCC conflicts with embedded assembly (__asm),
  4. # following GCC's recommendation to disable LTO per translation unit.
  5. if( "${CMAKE_CXX_COMPILER_ID}" MATCHES "Clang" OR "${CMAKE_CXX_COMPILER_ID}" STREQUAL "GNU")
  6. set_source_files_properties( libcontext.cpp PROPERTIES
  7. COMPILE_FLAGS "-fno-lto"
  8. )
  9. endif()
  10. list(APPEND LIBCONTEXT_SOURCES
  11. libcontext.cpp
  12. )
  13. if( MSVC )
  14. # we need our assembly helper until cmake 2.26.1 becomes standard on MSVC
  15. include( MSVCAssemblyHelper )
  16. if ( KICAD_BUILD_ARCH_X86 )
  17. list(APPEND LIBCONTEXT_ASM_SOURCES
  18. ${CMAKE_CURRENT_SOURCE_DIR}/make_i386_ms_pe_masm.asm
  19. ${CMAKE_CURRENT_SOURCE_DIR}/jump_i386_ms_pe_masm.asm
  20. )
  21. elseif( KICAD_BUILD_ARCH_X64 )
  22. list(APPEND LIBCONTEXT_ASM_SOURCES
  23. ${CMAKE_CURRENT_SOURCE_DIR}/make_x86_64_ms_pe_masm.asm
  24. ${CMAKE_CURRENT_SOURCE_DIR}/jump_x86_64_ms_pe_masm.asm
  25. )
  26. elseif( KICAD_BUILD_ARCH_ARM64 )
  27. list(APPEND LIBCONTEXT_ASM_SOURCES
  28. ${CMAKE_CURRENT_SOURCE_DIR}/make_arm64_aapcs_pe_armasm.asm
  29. ${CMAKE_CURRENT_SOURCE_DIR}/jump_arm64_aapcs_pe_armasm.asm
  30. )
  31. endif()
  32. if( KICAD_BUILD_ARCH_ARM64 )
  33. # ARM64 needs to use the compile_asm workaround
  34. compile_asm( TARGET libcontext ASM_FILES ${LIBCONTEXT_ASM_SOURCES} OUTPUT_OBJECTS ASM_SOURCES_OBJECTS )
  35. list(APPEND LIBCONTEXT_SOURCES ${ASM_SOURCES_OBJECTS})
  36. else()
  37. list(APPEND LIBCONTEXT_SOURCES ${LIBCONTEXT_ASM_SOURCES})
  38. endif()
  39. endif()
  40. add_library( libcontext STATIC
  41. ${LIBCONTEXT_SOURCES}
  42. )
  43. target_include_directories( libcontext PUBLIC
  44. ${CMAKE_CURRENT_SOURCE_DIR}
  45. )