Re-organisation + stdint.h and stddef.h
This commit is contained in:
@@ -1,14 +1,53 @@
|
||||
cmake_minimum_required(VERSION 3.5)
|
||||
project(photon)
|
||||
|
||||
file(GLOB_RECURSE photon_sources
|
||||
${CMAKE_SOURCE_DIR}/photon/*.c
|
||||
${CMAKE_SOURCE_DIR}/photon/*.h)
|
||||
message(STATUS "Sources: " ${photon_sources})
|
||||
macro(subdirlist result curdir)
|
||||
file(GLOB children RELATIVE ${curdir} ${curdir}/*)
|
||||
set(dirlist "")
|
||||
foreach (child ${children})
|
||||
if (IS_DIRECTORY ${curdir}/${child})
|
||||
list(APPEND dirlist ${child})
|
||||
endif()
|
||||
endforeach()
|
||||
set(${result} ${dirlist})
|
||||
endmacro()
|
||||
|
||||
add_library(photon_obj OBJECT ${photon_sources})
|
||||
subdirlist(machine_dirs ${CMAKE_CURRENT_SOURCE_DIR}/photon/libc/machine)
|
||||
|
||||
add_library(photon SHARED $<TARGET_OBJECTS:photon_obj>)
|
||||
add_library(photon_s STATIC $<TARGET_OBJECTS:photon_obj>)
|
||||
if (NOT PLATFORM)
|
||||
set(PLATFORM "linux")
|
||||
endif ()
|
||||
|
||||
set_property(TARGET photon_obj PROPERTY POSITION_INDEPENDENT_CODE ON)
|
||||
if (NOT MACHINE)
|
||||
set(supported_machines "")
|
||||
foreach (dir ${machine_dirs})
|
||||
set(supported_machines "${supported_machines}${dir} ")
|
||||
endforeach (dir)
|
||||
|
||||
message(FATAL_ERROR "No machine architecture specified.\n"
|
||||
" Supported machines: ${supported_machines}\n"
|
||||
" Ex. `cmake -DMACHINE=x86_64 <dir>`")
|
||||
endif ()
|
||||
|
||||
if (NOT EXISTS ${CMAKE_CURRENT_SOURCE_DIR}/photon/libc/sys/${PLATFORM})
|
||||
message(FATAL_ERROR "Unsupported platform: ${PLATFORM}")
|
||||
endif ()
|
||||
|
||||
|
||||
message(STATUS "Target platform: ${PLATFORM}")
|
||||
|
||||
set(photon_libc_sources "")
|
||||
set(generic_dirs string include)
|
||||
|
||||
foreach (dir ${generic_dirs})
|
||||
file(GLOB_RECURSE dir_sources ${CMAKE_CURRENT_SOURCE_DIR}/photon/libc/${dir}/*.c)
|
||||
set(photon_libc_sources ${photon_libc_sources} ${dir_sources})
|
||||
endforeach (dir)
|
||||
|
||||
file(GLOB_RECURSE platform_sources ${CMAKE_CURRENT_SOURCE_DIR}/photon/sys/${PLATFORM})
|
||||
set(photon_libc_sources ${photon_libc_sources} ${platform_sources})
|
||||
|
||||
add_library(c STATIC ${photon_libc_sources})
|
||||
target_compile_options(c PRIVATE -ffreestanding -nostdlib -nostdinc)
|
||||
|
||||
target_include_directories(c PRIVATE ${CMAKE_CURRENT_SOURCE_DIR}/photon/libc/include)
|
||||
|
||||
Reference in New Issue
Block a user