Clean up cmake files (Part 2)
I've kept just one cmake project, in the root directory. The subdirectories just set up the targets. The asm compiler is serached just one time, from the root directory cmake file. Global compilation flags are set in the root cmake file, and each subdirectory cmake file sets specific flags if necessary (e.g., programs need the -u_start specified)
This commit is contained in:
@@ -1,61 +1,4 @@
|
||||
# =============================================================================
|
||||
# Author: Enrico Fraccaroli
|
||||
# =============================================================================
|
||||
|
||||
# Set the minimum required version of cmake.
|
||||
cmake_minimum_required(VERSION 3.1...3.22)
|
||||
|
||||
# Initialize the project.
|
||||
project(tests C)
|
||||
|
||||
# =============================================================================
|
||||
# C WARNINGs
|
||||
# =============================================================================
|
||||
|
||||
# We need to specify the name of the entry function.
|
||||
set(CMAKE_C_FLAGS "${CMAKE_C_FLAGS} -u_start")
|
||||
|
||||
# Warning flags.
|
||||
set(CMAKE_C_FLAGS "${CMAKE_C_FLAGS} -Wall")
|
||||
set(CMAKE_C_FLAGS "${CMAKE_C_FLAGS} -Werror")
|
||||
set(CMAKE_C_FLAGS "${CMAKE_C_FLAGS} -Wpedantic")
|
||||
set(CMAKE_C_FLAGS "${CMAKE_C_FLAGS} -pedantic-errors")
|
||||
set(CMAKE_C_FLAGS "${CMAKE_C_FLAGS} -Wshadow")
|
||||
set(CMAKE_C_FLAGS "${CMAKE_C_FLAGS} -std=gnu99")
|
||||
|
||||
# Disable some specific warnings.
|
||||
set(CMAKE_C_FLAGS "${CMAKE_C_FLAGS} -Wno-unused-function")
|
||||
set(CMAKE_C_FLAGS "${CMAKE_C_FLAGS} -Wno-unused-variable")
|
||||
set(CMAKE_C_FLAGS "${CMAKE_C_FLAGS} -Wno-unknown-pragmas")
|
||||
set(CMAKE_C_FLAGS "${CMAKE_C_FLAGS} -Wno-missing-braces")
|
||||
set(CMAKE_C_FLAGS "${CMAKE_C_FLAGS} -Wno-unused-command-line-argument")
|
||||
|
||||
# Set the compiler options.
|
||||
set(CMAKE_C_FLAGS "${CMAKE_C_FLAGS} -static")
|
||||
set(CMAKE_C_FLAGS "${CMAKE_C_FLAGS} -nostdlib")
|
||||
set(CMAKE_C_FLAGS "${CMAKE_C_FLAGS} -nostdinc")
|
||||
set(CMAKE_C_FLAGS "${CMAKE_C_FLAGS} -fno-builtin")
|
||||
set(CMAKE_C_FLAGS "${CMAKE_C_FLAGS} -fno-stack-protector")
|
||||
set(CMAKE_C_FLAGS "${CMAKE_C_FLAGS} -fno-pic")
|
||||
set(CMAKE_C_FLAGS "${CMAKE_C_FLAGS} -fomit-frame-pointer")
|
||||
set(CMAKE_C_FLAGS "${CMAKE_C_FLAGS} -m32")
|
||||
set(CMAKE_C_FLAGS "${CMAKE_C_FLAGS} -march=i686")
|
||||
if(CMAKE_C_COMPILER_VERSION VERSION_GREATER_EQUAL 10)
|
||||
set(CMAKE_C_FLAGS "${CMAKE_C_FLAGS} -fcommon")
|
||||
endif()
|
||||
|
||||
if(CMAKE_BUILD_TYPE STREQUAL "Debug")
|
||||
set(CMAKE_C_FLAGS "${CMAKE_C_FLAGS} -g3")
|
||||
set(CMAKE_C_FLAGS "${CMAKE_C_FLAGS} -ggdb")
|
||||
set(CMAKE_C_FLAGS "${CMAKE_C_FLAGS} -O0")
|
||||
elseif(CMAKE_BUILD_TYPE STREQUAL "Release")
|
||||
set(CMAKE_C_FLAGS "${CMAKE_C_FLAGS} -O3")
|
||||
endif(CMAKE_BUILD_TYPE STREQUAL "Debug")
|
||||
|
||||
# =============================================================================
|
||||
# BUILD
|
||||
# =============================================================================
|
||||
# Add your file in this list.
|
||||
# List of programs.
|
||||
set(TEST_LIST
|
||||
t_gid.c
|
||||
t_alarm.c
|
||||
@@ -88,13 +31,16 @@ set(TEST_LIST
|
||||
t_mem.c
|
||||
t_shm_read.c
|
||||
)
|
||||
|
||||
# Set the directory where the compiled binaries will be placed.
|
||||
set(MENTOS_TESTS_DIR ${CMAKE_SOURCE_DIR}/files/bin/tests)
|
||||
|
||||
foreach(FILE_NAME ${TEST_LIST})
|
||||
# =========================================================================
|
||||
# TARGET NAMING
|
||||
# =========================================================================
|
||||
# Prepare the program name.
|
||||
string(REPLACE ".c" "" EXECUTABLE_NAME ${FILE_NAME})
|
||||
|
||||
# Set the name of the target.
|
||||
set(TARGET_NAME test_${EXECUTABLE_NAME})
|
||||
|
||||
|
||||
Reference in New Issue
Block a user