This repository has been archived by the owner on Nov 17, 2017. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 1
/
Copy pathCMakeLists.txt
69 lines (55 loc) · 2.13 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
59
60
61
62
63
64
65
66
67
68
69
cmake_minimum_required(VERSION 2.8)
project(cpu-simulator CXX)
# Version
set(VERSION_MAJOR 0)
set(VERSION_MINOR 1)
set(VERSION_PATCH 0)
# Compiler
message("Compiler:\n\t${CMAKE_CXX_COMPILER}")
# Set default build type to Release
if(CMAKE_BUILD_TYPE STREQUAL "")
set(CMAKE_BUILD_TYPE Release)
endif()
option(NO_ASSERT "Skip assertion" OFF)
if(NO_ASSERT)
add_definitions(-DFELIS_SIM_NO_ASSERT)
message("NO_ASSERT:\n\tOn")
else()
message("NO_ASSERT:\n\tOff")
endif()
# Set compile flags
set(CMAKE_CXX_FLAGS
"${CMAKE_CXX_FLAGS} -std=c++11 -Wall -Wextra -Wconversion -Wswitch-default -Wdisabled-optimization -Wformat -Winit-self -Woverloaded-virtual -Wfloat-equal")
set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -Wno-old-style-cast -Wno-pragmas -Wno-write-strings")
set(CMAKE_CXX_FLAGS_RELEASE "${CMAKE_CXX_FLAGS_RELEASE} -flto")
set(CMAKE_CXX_FLAGS_DEBUG "${CMAKE_CXX_FLAGS_DEBUG} -O0")
# Sources and headers
file(GLOB_RECURSE SOURCES ${CMAKE_CURRENT_LIST_DIR} src/*.cpp generated/*.cpp)
include_directories(${CMAKE_CURRENT_LIST_DIR}/src ${CMAKE_CURRENT_LIST_DIR}/generated)
# Echo compile flags
message("Build type:\n\t${CMAKE_BUILD_TYPE}")
if(CMAKE_BUILD_TYPE STREQUAL "Debug")
message("Compile flags:\n\t${CMAKE_CXX_FLAGS} ${CMAKE_CXX_FLAGS_DEBUG}")
elseif(CMAKE_BUILD_TYPE STREQUAL "Release")
message("Compile flags:\n\t${CMAKE_CXX_FLAGS} ${CMAKE_CXX_FLAGS_RELEASE}")
else()
message("Compile flags:\n\t${CMAKE_CXX_FLAGS}")
endif()
#add_subdirectory(tools)
add_subdirectory(test)
# Generate instruction file
add_custom_target(gen_instruction
COMMAND python ${CMAKE_CURRENT_LIST_DIR}/tools/gen_instruction.py
WORKING_DIRECTORY ${CMAKE_CURRENT_LIST_DIR}/generated)
add_executable(dec2bin tools/dec2bin.cpp)
# Build executable
add_executable(simulator ${SOURCES})
add_dependencies(simulator gen_instruction)
target_link_libraries(simulator ncurses)
# Clean
add_custom_target(cmake-clean
COMMAND rm -rf `find ${CMAKE_BINARY_DIR} -name \"*[cC][mM]ake*\" -and -not -name \"CMakeLists.txt\"`
COMMAND rm -rf `find ${CMAKE_BINARY_DIR} -name \"Makefile\"`)
add_custom_target(full-clean
COMMAND make clean
COMMAND make cmake-clean)