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 )
|
2021-03-05 02:31:53 +00:00
|
|
|
if( NOT LIBCONTEXT_USE_WINFIBER )
|
2023-03-04 23:34:23 +00:00
|
|
|
include( MSVCAssemblyHelper )
|
|
|
|
|
2021-03-12 15:05:38 +00:00
|
|
|
if ( KICAD_BUILD_ARCH_X86 )
|
2023-03-04 23:34:23 +00:00
|
|
|
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
|
2021-03-05 02:31:53 +00:00
|
|
|
)
|
2021-03-11 02:43:41 +00:00
|
|
|
elseif( KICAD_BUILD_ARCH_X64 )
|
2023-03-04 23:34:23 +00:00
|
|
|
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
|
2021-03-05 02:31:53 +00:00
|
|
|
)
|
2023-03-03 03:13:01 +00:00
|
|
|
elseif( KICAD_BUILD_ARCH_ARM64 )
|
2023-03-04 23:34:23 +00:00
|
|
|
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
|
2023-03-03 03:13:01 +00:00
|
|
|
)
|
2021-03-05 02:31:53 +00:00
|
|
|
endif()
|
2023-03-04 23:34:23 +00:00
|
|
|
|
|
|
|
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})
|
|
|
|
else()
|
|
|
|
list(APPEND LIBCONTEXT_SOURCES ${LIBCONTEXT_ASM_SOURCES})
|
|
|
|
endif()
|
2021-03-05 02:31:53 +00:00
|
|
|
else()
|
|
|
|
add_compile_definitions(LIBCONTEXT_USE_WINFIBER)
|
2021-03-04 01:27:37 +00:00
|
|
|
endif()
|
|
|
|
endif()
|
2019-12-28 18:17:55 +00:00
|
|
|
|
|
|
|
add_library( libcontext OBJECT
|
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}
|
|
|
|
)
|