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.
This commit is contained in:
parent
a8c30df08e
commit
c7918a2b8b
@ -3,15 +3,27 @@ cmake_minimum_required(VERSION 3.5)
|
|||||||
project(mtl LANGUAGES CXX C ASM)
|
project(mtl LANGUAGES CXX C ASM)
|
||||||
set(CMAKE_EXPORT_COMPILE_COMMANDS ON)
|
set(CMAKE_EXPORT_COMPILE_COMMANDS ON)
|
||||||
|
|
||||||
set(TARGET_SRC_FILES src/memcpy.s src/string.cpp src/string_view.cpp src/fixed.s)
|
message("Compiling MTL for ${CMAKE_SYSTEM_PROCESSOR}")
|
||||||
set(TARGET_PUB_INCLUDE_FILES include/mtl/utility.hpp include/mtl/string.hpp include/mtl/string_view.hpp include/mtl/fsm.hpp)
|
|
||||||
|
|
||||||
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)
|
|
||||||
|
|||||||
Loading…
x
Reference in New Issue
Block a user