-
Notifications
You must be signed in to change notification settings - Fork 55
/
Copy pathCMakeLists.txt
166 lines (134 loc) · 6.16 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
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
cmake_minimum_required(VERSION 2.8.8)
set(JLANG_CMAKE_SHOW_DETAIL 0)
set(JLANG_CMAKE_SHOW_MSVC_DETAIL 0)
set(JLANG_CMAKE_SHOW_DEBUG 1)
set(JLANG_CMAKE_SHOW_INFO 1)
# Add path for custom modules
set(CMAKE_MODULE_PATH
${CMAKE_MODULE_PATH}
"${CMAKE_CURRENT_SOURCE_DIR}/cmake"
"${CMAKE_CURRENT_SOURCE_DIR}/cmake/modules"
)
message(STATUS "CMAKE_SOURCE_DIR = " ${CMAKE_SOURCE_DIR})
message(STATUS "CMAKE_BINARY_DIR = " ${CMAKE_BINARY_DIR})
if (JLANG_CMAKE_SHOW_DETAIL)
message(STATUS "CMAKE_CURRENT_SOURCE_DIR = " ${CMAKE_CURRENT_SOURCE_DIR})
message(STATUS "CMAKE_CURRENT_BINARY_DIR = " ${CMAKE_CURRENT_BINARY_DIR})
endif()
message(STATUS "")
if (JLANG_CMAKE_SHOW_DETAIL)
message(STATUS "Now create a empty project.")
message(STATUS "")
endif()
# Create a empty project to get the project's variants value
project("")
message(STATUS "")
if (JLANG_CMAKE_SHOW_DETAIL)
message(STATUS "Create the empty project done.")
message(STATUS "")
endif()
# If we are not building as a part of JLVM, build JLang as an
# standalone project, using JLVM as an external library:
if (CMAKE_SOURCE_DIR STREQUAL CMAKE_CURRENT_SOURCE_DIR)
# set(CMAKE_C_COMPILER g++)
if (JLANG_CMAKE_SHOW_DETAIL)
message(STATUS "Start to detect the compiler environment ...")
message(STATUS "")
endif()
include(GetCompilerToolset)
# Get the Compiler Toolset
set(COMPILER_TOOLSET)
GetCompilerToolset(COMPILER_TOOLSET "cxx")
message(STATUS "COMPILER_TOOLSET = ${COMPILER_TOOLSET}")
message(STATUS "")
include(DisplayComplierEnv)
# Check Compiler Environment Values
DisplayCompilerEnvironment()
if (JLANG_CMAKE_SHOW_DETAIL)
message(STATUS "Create the real project files.")
endif()
if ((NOT MSVC) OR (COMPILER_TOOLSET STREQUAL ""))
# message(STATUS "The real project filename is \"RingQueue\".")
project("RingQueue")
else()
# message(STATUS "The real project filename is \"RingQueue_${COMPILER_TOOLSET}\".")
project("RingQueue_${COMPILER_TOOLSET}")
endif()
if (JLANG_CMAKE_SHOW_DETAIL)
message(STATUS "Create the real project files done.")
endif()
message(STATUS "")
# include_directories(${PROJECT_SOURCE_DIR}/include)
# add_library(util STATIC ${SRC_LIST})
# add_library(libhello SHARED ${LIB_SRC})
# link_directories(${PROJECT_SOURCE_DIR}/lib)
message(STATUS "PROJECT_SOURCE_DIR = " ${PROJECT_SOURCE_DIR})
message(STATUS "PROJECT_BINARY_DIR = " ${PROJECT_BINARY_DIR})
message(STATUS "")
set(EXECUTABLE_OUTPUT_PATH ${PROJECT_BINARY_DIR}/bin)
set(LIBRARY_OUTPUT_PATH ${PROJECT_BINARY_DIR}/lib)
message(STATUS "EXECUTABLE_OUTPUT_PATH = " ${EXECUTABLE_OUTPUT_PATH})
message(STATUS "LIBRARY_OUTPUT_PATH = " ${LIBRARY_OUTPUT_PATH})
message(STATUS "")
set(TOOLS_BINARY_DIR ${PROJECT_BINARY_DIR}/bin)
set(LIBRARY_DIR ${PROJECT_BINARY_DIR}/lib)
set(INCLUDE_DIR ${PROJECT_SOURCE_DIR}/src)
set(JLVM_OBJ_ROOT ${PROJECT_BINARY_DIR})
set(MAIN_SRC_DIR ${PROJECT_BINARY_DIR}/src)
set(JLVM_INCLUDE_DIR ${JLVM_BINARY_DIR}/src)
set(JLVM_TOOLS_BINARY_DIR ${TOOLS_BINARY_DIR} CACHE PATH "Path to jlvm/bin")
set(JLVM_LIBRARY_DIR ${LIBRARY_DIR} CACHE PATH "Path to jlvm/lib")
set(JLVM_MAIN_INCLUDE_DIR ${INCLUDE_DIR} CACHE PATH "Path to jlvm/include")
set(JLVM_BINARY_DIR ${JLVM_OBJ_ROOT} CACHE PATH "Path to JLVM build tree")
set(JLVM_MAIN_SRC_DIR ${MAIN_SRC_DIR} CACHE PATH "Path to JLVM source tree")
if (EXISTS ${JLVM_INCLUDE_DIR})
include_directories("${JLVM_INCLUDE_DIR}" "${JLVM_BINARY_DIR}/include" "${JLVM_MAIN_INCLUDE_DIR}")
else()
include_directories("${JLVM_BINARY_DIR}/include" "${JLVM_MAIN_INCLUDE_DIR}")
endif()
link_directories("${JLVM_LIBRARY_DIR}")
#
# In CMake, how do I work around the Debug and Release directories Visual Studio 2010 tries to add?
#
# See: http://stackoverflow.com/questions/7747857/in-cmake-how-do-i-work-around-the-debug-and-release-directories-visual-studio-2
#
# First for the generic no-config case (e.g. with mingw)
set(CMAKE_RUNTIME_OUTPUT_DIRECTORY ${CMAKE_BINARY_DIR}/bin)
set(CMAKE_LIBRARY_OUTPUT_DIRECTORY ${CMAKE_BINARY_DIR}/lib)
set(CMAKE_ARCHIVE_OUTPUT_DIRECTORY ${CMAKE_BINARY_DIR}/lib)
# Second, for multi-config builds (e.g. msvc)
foreach (OUTPUT_CONFIG ${CMAKE_CONFIGURATION_TYPES})
#string(TOUPPER ${OUTPUT_CONFIG} OUTPUT_CONFIG)
string(TOLOWER ${OUTPUT_CONFIG} OUTPUT_CONFIG)
set(CMAKE_RUNTIME_OUTPUT_DIRECTORY_${OUTPUT_CONFIG} ${CMAKE_BINARY_DIR}/bin/${OUTPUT_CONFIG})
set(CMAKE_LIBRARY_OUTPUT_DIRECTORY_${OUTPUT_CONFIG} ${CMAKE_BINARY_DIR}/lib/${OUTPUT_CONFIG})
set(CMAKE_ARCHIVE_OUTPUT_DIRECTORY_${OUTPUT_CONFIG} ${CMAKE_BINARY_DIR}/lib/${OUTPUT_CONFIG})
endforeach(OUTPUT_CONFIG CMAKE_CONFIGURATION_TYPES)
endif()
set(JLANG_SOURCE_DIR ${CMAKE_CURRENT_SOURCE_DIR})
set(JLANG_BINARY_DIR ${CMAKE_CURRENT_BINARY_DIR})
if (CMAKE_SOURCE_DIR STREQUAL CMAKE_BINARY_DIR AND NOT MSVC_IDE)
message(FATAL_ERROR "In-source builds are not allowed. CMake would overwrite "
"the makefiles distributed with JLVM. Please create a directory and run cmake "
"from there, passing the path to this source directory as the last argument. "
"This process created the file `CMakeCache.txt' and the directory "
"`CMakeFiles'. Please delete them.")
endif()
# Add appropriate flags for GCC
if (JLVM_COMPILER_IS_GCC_COMPATIBLE)
set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -fno-common -Woverloaded-virtual -Wcast-qual -fno-strict-aliasing")
# Enable -pedantic for Clang even if it's not enabled for JLVM.
if (NOT JLVM_ENABLE_PEDANTIC)
set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -pedantic -Wno-long-long")
endif ()
check_cxx_compiler_flag("-Werror -Wnested-anon-types" CXX_SUPPORTS_NO_NESTED_ANON_TYPES_FLAG)
if (CXX_SUPPORTS_NO_NESTED_ANON_TYPES_FLAG)
set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -Wno-nested-anon-types" )
endif()
endif ()
set(CMAKE_INCLUDE_CURRENT_DIR ON)
include_directories(BEFORE
${CMAKE_CURRENT_BINARY_DIR}/include
${CMAKE_CURRENT_SOURCE_DIR}/include
)
add_subdirectory(src/RingQueue)