1ec33767ab
every system component now has its own self-contained build system, and a seed file describing the component and its build system and dependencies. a new tool, meadow, collects and uses these seed files to build the components into a full system. meadow also manages the target system root and a host prefix where toolchain tools are installed to. the build system has also been updated to use a new $ARCH-rosetta-gcc compiler, and the patches files necessary to build it have been added to toolchain/cross-compiler.
47 lines
1.8 KiB
CMake
47 lines
1.8 KiB
CMake
cmake_minimum_required(VERSION 3.31)
|
|
project(libc-pthread C ASM)
|
|
|
|
set(pthread_source_dirs thread mutex)
|
|
|
|
foreach (dir ${pthread_source_dirs})
|
|
file(GLOB dir_sources ${CMAKE_CURRENT_SOURCE_DIR}/${dir}/*.c)
|
|
file(GLOB dir_headers ${CMAKE_CURRENT_SOURCE_DIR}/${dir}/*.h)
|
|
|
|
set(pthread_sources ${pthread_sources} ${dir_sources})
|
|
set(pthread_headers ${pthread_headers} ${dir_headers})
|
|
endforeach (dir)
|
|
|
|
file(GLOB pthread_sys_sources
|
|
${CMAKE_CURRENT_SOURCE_DIR}/sys/${CMAKE_SYSTEM_PROCESSOR}/*.c
|
|
${CMAKE_CURRENT_SOURCE_DIR}/sys/${CMAKE_SYSTEM_PROCESSOR}/*.S)
|
|
|
|
set(pthread_sources ${pthread_sources} ${pthread_sys_sources})
|
|
|
|
set(pthread_headers ${pthread_headers} ${CMAKE_CURRENT_SOURCE_DIR}/include/pthread.h)
|
|
set(pthread_public_include_dir ${CMAKE_CURRENT_SOURCE_DIR}/include)
|
|
|
|
if (PTHREAD_STATIC)
|
|
add_library(libc-pthread STATIC ${pthread_sources} ${pthread_headers})
|
|
target_link_libraries(libc-pthread PRIVATE libc-io libmagenta)
|
|
target_include_directories(libc-pthread PUBLIC
|
|
${public_include_dirs}
|
|
${CMAKE_CURRENT_SOURCE_DIR}/include)
|
|
set_target_properties(libc-pthread PROPERTIES PREFIX "")
|
|
target_compile_definitions(libc-pthread PRIVATE ENABLE_GLOBAL_HEAP=1 BUILD_STATIC=1)
|
|
install(TARGETS libc-pthread)
|
|
else ()
|
|
add_library(libpthread SHARED ${pthread_sources} ${pthread_headers})
|
|
target_link_libraries(libpthread PRIVATE magenta)
|
|
target_link_libraries(libpthread PUBLIC c)
|
|
target_include_directories(libpthread PUBLIC
|
|
${public_include_dirs}
|
|
${CMAKE_CURRENT_SOURCE_DIR}/include)
|
|
set_target_properties(libpthread PROPERTIES PREFIX "")
|
|
target_compile_options(libpthread PRIVATE -ffreestanding -nostdlib)
|
|
target_link_options(libpthread PRIVATE -ffreestanding -nostdlib)
|
|
target_compile_definitions(libpthread PRIVATE ENABLE_GLOBAL_HEAP=1 BUILD_SHARED=1)
|
|
install(TARGETS libpthread)
|
|
endif ()
|
|
|
|
install(FILES include/pthread.h DESTINATION include)
|