-
Notifications
You must be signed in to change notification settings - Fork 1
/
CMakeLists.txt
59 lines (45 loc) · 1.81 KB
/
CMakeLists.txt
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
#
# ECG: Emulator Code Generator.
# Copyright (C) 2014, Tyler J. Stachecki.
#
# This file is subject to the terms and conditions defined in
# 'LICENSE', which is part of this source code package.
#
# TODO/FIXME: Configure for multiple architectures.
# Right now, we only support x86_64, so it's okay...
cmake_minimum_required(VERSION 2.6)
project(ecg)
if ("${CMAKE_C_COMPILER_ID}" MATCHES "GNU")
set(CMAKE_C_FLAGS "-Wall -Wextra -std=c99 -msse2 -D_POSIX_SOURCE")
set(CMAKE_C_FLAGS_DEBUG "-ggdb3 -g3 -O0")
set(CMAKE_C_FLAGS_MINSIZEREL "-Os -DNDEBUG")
set(CMAKE_C_FLAGS_RELEASE "-O2 -DNDEBUG")
set(CMAKE_C_FLAGS_RELWITHDEBINFO "-Og")
endif ("${CMAKE_C_COMPILER_ID}" MATCHES "GNU")
include_directories(${PROJECT_SOURCE_DIR})
# Glob all the files together and build a static library.
file(GLOB BACKEND ${PROJECT_SOURCE_DIR}/backends/*.c)
file(GLOB LIB_HEADERS ${PROJECT_SOURCE_DIR}/ecg/*.c)
file(GLOB LIB_SOURCES ${PROJECT_SOURCE_DIR}/ecg/*.c)
add_library(ecg STATIC ${LIB_SOURCES} ${BACKEND})
# Optionally build all of the test programs.
option(BUILD_TESTS "Build test programs?" OFF)
if (BUILD_TESTS)
file(GLOB TEST_FILES ${PROJECT_SOURCE_DIR}/tests/*.c)
foreach(SOURCE_FILE ${TEST_FILES})
get_filename_component(BINARY_NAME ${SOURCE_FILE} NAME_WE)
add_executable(${BINARY_NAME} ${SOURCE_FILE})
target_link_libraries(${BINARY_NAME} ecg)
endforeach(SOURCE_FILE ${TEST_FILES})
endif (BUILD_TESTS)
# Optionally build a shared library.
option (BUILD_SHARED "Build a shared library?" OFF)
if (BUILD_SHARED)
add_library(ecg1 SHARED ${LIB_SOURCES})
endif (BUILD_SHARED)
# Install all the header files and libraries to their respective locations.
install(FILES ${LIB_HEADERS} DESTINATION include/ecg)
install(TARGETS ecg DESTINATION lib)
if (BUILD_SHARED)
install(TARGETS ecg1 DESTINATION lib)
endif (BUILD_SHARED)