2 # Copyright (c) 2016 Samsung Electronics Co., Ltd All Rights Reserved
4 # Contact: Krzysztof Jackiewicz <k.jackiewicz@samsung.com>
6 # Licensed under the Apache License, Version 2.0 (the "License");
7 # you may not use this file except in compliance with the License.
8 # You may obtain a copy of the License at
10 # http://www.apache.org/licenses/LICENSE-2.0
12 # Unless required by applicable law or agreed to in writing, software
13 # distributed under the License is distributed on an "AS IS" BASIS,
14 # WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
15 # See the License for the specific language governing permissions and
16 # limitations under the License
19 # @file CMakeLists.txt
20 # @author Dariusz Michaluk (d.michaluk@samsung.com)
23 CMAKE_MINIMUM_REQUIRED (VERSION 2.6.2)
28 ## pkgconfig ###################################################################
29 INCLUDE(FindPkgConfig)
31 ## default CMAKE_INSTALL_* variables ###########################################
32 INCLUDE(GNUInstallDirs)
34 ## Color output if it's possible:
35 IF (( "${CMAKE_C_COMPILER_ID}" STREQUAL "GNU" AND NOT (CMAKE_C_COMPILER_VERSION VERSION_LESS 4.9))
36 OR ("${CMAKE_C_COMPILER_ID}" STREQUAL "Clang" ))
38 IF (OWL_BUILD_FORCE_COMPILER_COLORS)
39 SET(CMAKE_C_FLAGS "${CMAKE_C_FLAGS} -fdiagnostics-color=always")
43 ## Compiler flags, depending on the build type #################################
44 IF(NOT CMAKE_BUILD_TYPE)
45 SET(CMAKE_BUILD_TYPE "DEBUG")
46 ENDIF(NOT CMAKE_BUILD_TYPE)
48 ## Print build information #####################################################
49 MESSAGE(STATUS "-------------------------------------------------")
50 MESSAGE(STATUS "Compiler: " ${CMAKE_C_COMPILER_ID})
51 MESSAGE(STATUS "Compiler version: " ${CMAKE_C_COMPILER_VERSION})
52 MESSAGE(STATUS "Build type: " ${CMAKE_BUILD_TYPE})
53 MESSAGE(STATUS "-------------------------------------------------")
55 SET(CMAKE_C_FLAGS_DEBUG "-std=c99 -O0 -ggdb -Wp,-U_FORTIFY_SOURCE")
56 SET(CMAKE_C_FLAGS_RELEASE "-std=c99 -O2 -DNDEBUG")
58 ADD_DEFINITIONS("-fPIC") # Position Independent Code
59 ADD_DEFINITIONS("-Werror") # Make all warnings into errors
60 ADD_DEFINITIONS("-Wall") # Generate all warnings
61 #ADD_DEFINITIONS("-Wextra") # Generate even more extra warnings
62 #ADD_DEFINITIONS("-pedantic") # Be pedantic
63 #ADD_DEFINITIONS("-pedantic-errors") # Make pedantic warnings into errors
64 ADD_DEFINITIONS(-DPROJECT_SOURCE_DIR="${PROJECT_SOURCE_DIR}")
66 IF("${CMAKE_C_COMPILER_ID}" STREQUAL "Clang")
67 # Warn about documentation problems
68 SET(CMAKE_C_FLAGS "${CMAKE_C_FLAGS} -Wdocumentation")
69 # Enable all diagnostics
70 #SET(CMAKE_C_FLAGS "${CMAKE_C_FLAGS} -Weverything")
73 ## Subdirectories ##############################################################
74 SET(API_FOLDER ${PROJECT_SOURCE_DIR}/api)
75 SET(EXAMPLES_FOLDER ${PROJECT_SOURCE_DIR}/examples)
76 SET(SRC_FOLDER ${PROJECT_SOURCE_DIR}/src)
77 SET(TEST_FOLDER ${PROJECT_SOURCE_DIR}/test)
79 IF(NOT DEFINED LIB_INSTALL_DIR)
80 SET(LIB_INSTALL_DIR "${CMAKE_INSTALL_PREFIX}/${CMAKE_INSTALL_LIBDIR}")
81 ENDIF(NOT DEFINED LIB_INSTALL_DIR)
83 IF(NOT DEFINED INCLUDE_INSTALL_DIR)
84 SET(INCLUDE_INSTALL_DIR "${CMAKE_INSTALL_PREFIX}/${CMAKE_INSTALL_INCLUDEDIR}")
85 ENDIF(NOT DEFINED INCLUDE_INSTALL_DIR)
87 IF(NOT DEFINED BIN_INSTALL_DIR)
88 SET(BIN_INSTALL_DIR "${CMAKE_INSTALL_PREFIX}/${CMAKE_INSTALL_BINDIR}")
89 ENDIF(NOT DEFINED BIN_INSTALL_DIR)
91 ADD_SUBDIRECTORY(${SRC_FOLDER})
92 #ADD_SUBDIRECTORY(${TEST_FOLDER})
93 ADD_SUBDIRECTORY(${EXAMPLES_FOLDER})