CMake fully integrated.

This commit is contained in:
Nicolás Ortega Froysa 2018-03-14 21:44:41 +01:00
parent cdd614e7ba
commit 2d447773b8
No known key found for this signature in database
GPG Key ID: FEC70E3BAE2E69BF
4 changed files with 20 additions and 16 deletions

1
.gitignore vendored
View File

@ -1,2 +1,3 @@
# ignore binary files # ignore binary files
build/* build/*
!build/.keep

View File

@ -15,8 +15,7 @@
# along with this program. If not, see <http://www.gnu.org/licenses/>. # along with this program. If not, see <http://www.gnu.org/licenses/>.
cmake_minimum_required(VERSION 2.8) cmake_minimum_required(VERSION 2.8)
project(colonel) project(colonel C ASM)
enable_language(ASM_NASM)
set(TARGET_NAME "colonel.bin") set(TARGET_NAME "colonel.bin")
@ -28,9 +27,11 @@ string(TOLOWER ${CMAKE_BUILD_TYPE} CMAKE_BUILD_TYPE)
message(STATUS "Build type: ${CMAKE_BUILD_TYPE}") message(STATUS "Build type: ${CMAKE_BUILD_TYPE}")
# flags # flags
set(CMAKE_C_FLAGS "-std=c99 -ffreestanding -fno-builtin -nostdlibinc -Wall -Wextra") set(CMAKE_C_FLAGS "-std=c99 -ffreestanding -fno-builtin -Wall -Wextra")
set(CMAKE_C_FLAGS_DEBUG "-g -O0") set(CMAKE_C_FLAGS_DEBUG "-g -O0")
set(CMAKE_C_FLAGS_RELEASE "-O3") set(CMAKE_C_FLAGS_RELEASE "-O3")
set(CMAKE_ASM_FLAGS "")
set(CMAKE_ASM_FLAGS_RELEASE "")
include_directories( include_directories(
"src/") "src/")
@ -45,14 +46,14 @@ if(${CMAKE_SYSTEM_PROCESSOR} MATCHES "i.86")
src/kernel/arch/x86/boot.s src/kernel/arch/x86/boot.s
${SRCS} ${SRCS}
src/kernel/arch/x86/tty.c) src/kernel/arch/x86/tty.c)
set(CMAKE_EXE_LINKER_FLAGS "-T src/kernel/arch/x86/linker.ld") set_source_files_properties(
endif() src/kernel/arch/x86/boot.s
PROPERTIES COMPILE_FLAGS ""
if(NOT CMAKE_BUILD_TYPE STREQUAL "debug" AND )
NOT CMAKE_BUILD_TYPE STREQUAL "relwithdebinfo") set(CMAKE_EXE_LINKER_FLAGS
add_definitions("-DNDEBUG") "-T ${CMAKE_CURRENT_SOURCE_DIR}/src/kernel/arch/x86/linker.ld -ffreestanding -nostdlib")
else() include_directories(
add_definitions("-DDEBUG") "src/kernel/arch/x86/")
endif() endif()
add_executable(${TARGET_NAME} ${SRCS}) add_executable(${TARGET_NAME} ${SRCS})

0
build/.keep Normal file
View File

View File

@ -1,6 +1,8 @@
set(CMAKE_SYSTEM_NAME "Generic") set(CMAKE_SYSTEM_NAME Generic)
set(CMAKE_SYSTEM_PROCESSOR "i686") set(CMAKE_SYSTEM_PROCESSOR i686)
set(triple "i686-elf")
set(CMAKE_C_COMPILER clang) set(CMAKE_C_COMPILER i686-elf-gcc)
set(CMAKE_C_COMPILER_TARGET ${triple}) set(CMAKE_C_COMPILER_WORKS TRUE)
set(CMAKE_CXX_COMPILER i686-elf-g++)
set(CMAKE_CXX_COMPILER_WORKS TRUE)
set(CMAKE_ASM_COMPILER i686-elf-as)