From c7918a2b8befdc59e5644ced9ae6093c6c5fc98f Mon Sep 17 00:00:00 2001 From: Myles Busig Date: Sun, 10 Mar 2024 21:55:50 -0600 Subject: [PATCH] Update CMakeLists.txt to use globbing, and support arch. dependent files 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 major issue with globbing. May have a performance impact, but it should be negligible compared to the time spent building. --- CMakeLists.txt | 28 ++++++++++++++++++++-------- src/{ => armv4t}/fixed.s | 0 src/{ => armv4t}/memcpy.s | 0 3 files changed, 20 insertions(+), 8 deletions(-) rename src/{ => armv4t}/fixed.s (100%) rename src/{ => armv4t}/memcpy.s (100%) diff --git a/CMakeLists.txt b/CMakeLists.txt index c446016..2c2fa1e 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -3,15 +3,27 @@ cmake_minimum_required(VERSION 3.5) project(mtl LANGUAGES CXX C ASM) set(CMAKE_EXPORT_COMPILE_COMMANDS ON) -set(TARGET_SRC_FILES src/memcpy.s src/string.cpp src/string_view.cpp src/fixed.s) -set(TARGET_PUB_INCLUDE_FILES include/mtl/utility.hpp include/mtl/string.hpp include/mtl/string_view.hpp include/mtl/fsm.hpp) +message("Compiling MTL for ${CMAKE_SYSTEM_PROCESSOR}") -add_library(${PROJECT_NAME} STATIC ${TARGET_SRC_FILES} ${TARGET_PUB_INCLUDE_FILES}) +# 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 +# major issue with globbing. May have a performance impact, but it should be +# negligible compared to the time spent building. +file(GLOB mtl_sources_common LIST_DIRECTORIES false CONFIGURE_DEPENDS src/*.cpp src/*.c src/*.s) +file(GLOB mtl_sources_armv4t LIST_DIRECTORIES false CONFIGURE_DEPENDS src/armv4t/*.cpp src/armv4t/*.c src/armv4t/*.s) -target_include_directories(${PROJECT_NAME} PUBLIC "include") +set(mtl_include_common "include") +set(mtl_include_armv4t "include/armv4t") -set_target_properties(${PROJECT_NAME} PROPERTIES PUBLIC_HEADER "${TARGET_PUB_INCLUDE_FILES}") +add_library(${PROJECT_NAME} STATIC) + +target_sources(${PROJECT_NAME} PRIVATE "${mtl_sources_common}") +target_include_directories(${PROJECT_NAME} PUBLIC "${mtl_include_common}") + +if (CMAKE_SYSTEM_PROCESSOR STREQUAL "armv4t") + target_sources(${PROJECT_NAME} PRIVATE "${mtl_sources_armv4t}") + target_include_directories(${PROJECT_NAME} PUBLIC "${mtl_include_armv4t}") +endif() + +# TODO: Support installing library -install(TARGETS ${PROJECT_NAME} - LIBRARY DESTINATION lib - PUBLIC_HEADER DESTINATION include) diff --git a/src/fixed.s b/src/armv4t/fixed.s similarity index 100% rename from src/fixed.s rename to src/armv4t/fixed.s diff --git a/src/memcpy.s b/src/armv4t/memcpy.s similarity index 100% rename from src/memcpy.s rename to src/armv4t/memcpy.s