2019-12-28 18:17:55 +00:00
|
|
|
# The libcontext library is only included inside common, so we create it as an
|
|
|
|
# object library and then add the objects to common.
|
|
|
|
|
|
|
|
# Link-time optimization (LTO) on GCC conflicts with embedded assembly (__asm),
|
|
|
|
# following GCC's recommendation to disable LTO per translation unit.
|
|
|
|
if( "${CMAKE_CXX_COMPILER_ID}" MATCHES "Clang" OR "${CMAKE_CXX_COMPILER_ID}" STREQUAL "GNU")
|
|
|
|
set_source_files_properties( libcontext.cpp PROPERTIES
|
|
|
|
COMPILE_FLAGS "-fno-lto"
|
|
|
|
)
|
|
|
|
endif()
|
|
|
|
|
2021-03-04 01:27:37 +00:00
|
|
|
list(APPEND LIBCONTEXT_SOURCES
|
|
|
|
libcontext.cpp
|
|
|
|
)
|
|
|
|
|
|
|
|
if( MSVC )
|
2023-04-10 22:07:10 +00:00
|
|
|
# we need our assembly helper until cmake 2.26.1 becomes standard on MSVC
|
|
|
|
include( MSVCAssemblyHelper )
|
|
|
|
|
|
|
|
if ( KICAD_BUILD_ARCH_X86 )
|
|
|
|
list(APPEND LIBCONTEXT_ASM_SOURCES
|
|
|
|
${CMAKE_CURRENT_SOURCE_DIR}/make_i386_ms_pe_masm.asm
|
|
|
|
${CMAKE_CURRENT_SOURCE_DIR}/jump_i386_ms_pe_masm.asm
|
|
|
|
)
|
|
|
|
elseif( KICAD_BUILD_ARCH_X64 )
|
|
|
|
list(APPEND LIBCONTEXT_ASM_SOURCES
|
|
|
|
${CMAKE_CURRENT_SOURCE_DIR}/make_x86_64_ms_pe_masm.asm
|
|
|
|
${CMAKE_CURRENT_SOURCE_DIR}/jump_x86_64_ms_pe_masm.asm
|
|
|
|
)
|
|
|
|
elseif( KICAD_BUILD_ARCH_ARM64 )
|
|
|
|
list(APPEND LIBCONTEXT_ASM_SOURCES
|
|
|
|
${CMAKE_CURRENT_SOURCE_DIR}/make_arm64_aapcs_pe_armasm.asm
|
|
|
|
${CMAKE_CURRENT_SOURCE_DIR}/jump_arm64_aapcs_pe_armasm.asm
|
|
|
|
)
|
|
|
|
endif()
|
|
|
|
|
|
|
|
if( KICAD_BUILD_ARCH_ARM64 )
|
|
|
|
# ARM64 needs to use the compile_asm workaround
|
|
|
|
compile_asm( TARGET libcontext ASM_FILES ${LIBCONTEXT_ASM_SOURCES} OUTPUT_OBJECTS ASM_SOURCES_OBJECTS )
|
|
|
|
|
|
|
|
list(APPEND LIBCONTEXT_SOURCES ${ASM_SOURCES_OBJECTS})
|
2021-03-05 02:31:53 +00:00
|
|
|
else()
|
2023-04-10 22:07:10 +00:00
|
|
|
list(APPEND LIBCONTEXT_SOURCES ${LIBCONTEXT_ASM_SOURCES})
|
2021-03-04 01:27:37 +00:00
|
|
|
endif()
|
|
|
|
endif()
|
2019-12-28 18:17:55 +00:00
|
|
|
|
2023-04-11 01:22:04 +00:00
|
|
|
add_library( libcontext STATIC
|
2021-03-04 01:27:37 +00:00
|
|
|
${LIBCONTEXT_SOURCES}
|
2019-12-28 18:17:55 +00:00
|
|
|
)
|
|
|
|
|
|
|
|
target_include_directories( libcontext PUBLIC
|
|
|
|
${CMAKE_CURRENT_SOURCE_DIR}
|
|
|
|
)
|