Change CMake to not build the common implementation when there is a
platform specific alternative
This commit is contained in:
parent
04fcbecc43
commit
844904cca4
@ -5,6 +5,30 @@ set(CMAKE_EXPORT_COMPILE_COMMANDS ON)
|
|||||||
|
|
||||||
message("Compiling MTL for ${CMAKE_SYSTEM_PROCESSOR}")
|
message("Compiling MTL for ${CMAKE_SYSTEM_PROCESSOR}")
|
||||||
|
|
||||||
|
# Adds the sources to the target if there is not already a source with the
|
||||||
|
# same filename (ie. no clobber/noc). (Note, the files can be in different directories)
|
||||||
|
function(target_sources_noc target linkage sources)
|
||||||
|
get_target_property(cur_sources ${target} SOURCES)
|
||||||
|
|
||||||
|
foreach(src_fq ${sources})
|
||||||
|
cmake_path(GET src_fq FILENAME src)
|
||||||
|
set(already_exists false)
|
||||||
|
|
||||||
|
# Check if the source already exists
|
||||||
|
foreach (csrc_fq ${cur_sources})
|
||||||
|
cmake_path(GET csrc_fq FILENAME csrc)
|
||||||
|
if (src STREQUAL csrc)
|
||||||
|
set(already_exists true)
|
||||||
|
break()
|
||||||
|
endif()
|
||||||
|
endforeach()
|
||||||
|
|
||||||
|
if (NOT already_exists)
|
||||||
|
target_sources(${target} ${linkage} "${src_fq}")
|
||||||
|
endif()
|
||||||
|
endforeach()
|
||||||
|
endfunction()
|
||||||
|
|
||||||
# CONFIGURE_DEPENDS option was added in CMake v3.12. This option allows the
|
# CONFIGURE_DEPENDS option was added in CMake v3.12. This option allows the
|
||||||
# build system to automatically re-run CMake if the glob changes, solving the
|
# build system to automatically re-run CMake if the glob changes, solving the
|
||||||
# major issue with globbing. May have a performance impact, but it should be
|
# major issue with globbing. May have a performance impact, but it should be
|
||||||
@ -19,20 +43,23 @@ set(mtl_include_debug "include/debug")
|
|||||||
|
|
||||||
add_library(${PROJECT_NAME} STATIC)
|
add_library(${PROJECT_NAME} STATIC)
|
||||||
|
|
||||||
target_sources(${PROJECT_NAME} PRIVATE "${mtl_sources_common}")
|
set(mtl_processor_generic true)
|
||||||
target_include_directories(${PROJECT_NAME} PUBLIC "${mtl_include_common}")
|
set(mtl_platform_generic true)
|
||||||
|
|
||||||
if (CMAKE_BUILD_TYPE STREQUAL "Debug")
|
if (CMAKE_SYSTEM_NAME STREQUAL "NintendoGBA")
|
||||||
target_sources(${PROJECT_NAME} PRIVATE "${mtl_sources_debug}")
|
target_sources_noc(${PROJECT_NAME} PRIVATE "${mtl_sources_gba}")
|
||||||
target_include_directories(${PROJECT_NAME} PUBLIC "${mtl_include_debug}")
|
|
||||||
endif()
|
endif()
|
||||||
|
|
||||||
if (CMAKE_SYSTEM_PROCESSOR STREQUAL "armv4t")
|
if (CMAKE_SYSTEM_PROCESSOR STREQUAL "armv4t")
|
||||||
target_sources(${PROJECT_NAME} PRIVATE "${mtl_sources_armv4t}")
|
target_sources_noc(${PROJECT_NAME} PRIVATE "${mtl_sources_armv4t}")
|
||||||
endif()
|
endif()
|
||||||
|
|
||||||
if (CMAKE_SYSTEM_NAME STREQUAL "NintendoGBA")
|
target_sources_noc(${PROJECT_NAME} PRIVATE "${mtl_sources_common}")
|
||||||
target_sources(${PROJECT_NAME} PRIVATE "${mtl_sources_gba}")
|
target_include_directories(${PROJECT_NAME} PUBLIC "${mtl_include_common}")
|
||||||
|
|
||||||
|
if (CMAKE_BUILD_TYPE STREQUAL "Debug")
|
||||||
|
target_sources_noc(${PROJECT_NAME} PRIVATE "${mtl_sources_debug}")
|
||||||
|
target_include_directories(${PROJECT_NAME} PUBLIC "${mtl_include_debug}")
|
||||||
endif()
|
endif()
|
||||||
|
|
||||||
# TODO: Support installing library
|
# TODO: Support installing library
|
||||||
|
|||||||
Loading…
x
Reference in New Issue
Block a user