aboutsummaryrefslogtreecommitdiffstats
path: root/CMakeLists.txt
diff options
context:
space:
mode:
authorRenato Filho <renato.filho@openbossa.org>2010-05-28 10:59:55 -0300
committerRenato Filho <renato.filho@openbossa.org>2010-05-28 11:22:10 -0300
commit4bd6afcca5854f6f0d706f226ca8ddf825349b76 (patch)
tree651ca14c30f725e5916aee7d490a3d68d3b082e4 /CMakeLists.txt
parent48f7e2ae85aeb2d3a5273f05d4f7bcc54e0caac4 (diff)
Disabled GCC optimization flags by default.
Reviewer: Luciano Wolf <luciano.wolf@openbossa.org>, Marcelo Lira <marcelo.lira@openbossa.org>
Diffstat (limited to 'CMakeLists.txt')
-rw-r--r--CMakeLists.txt22
1 files changed, 18 insertions, 4 deletions
diff --git a/CMakeLists.txt b/CMakeLists.txt
index 87744eea..258e7d1c 100644
--- a/CMakeLists.txt
+++ b/CMakeLists.txt
@@ -7,11 +7,25 @@ find_package(ApiExtractor REQUIRED)
option(BUILD_TESTS "Build tests." TRUE)
-if (MSVC)
+if(MSVC)
set(CMAKE_CXX_FLAGS "/DWIN32 /D_WINDOWS /w /EHsc- /GS- /GR- /DGENRUNNER_BUILD -D_SCL_SECURE_NO_WARNINGS")
-else (MSVC)
- set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -Wall -fvisibility=hidden")
-endif(MSVC)
+elseif(CMAKE_HOST_UNIX)
+ option(ENABLE_GCC_OPTIMIZATION "Enable specific GCC flags to optimize library size and performance. Only available on Release Mode" 0)
+ set(CMAKE_CXX_FLAGS "-Wall -fvisibility=hidden")
+ set(CMAKE_CXX_FLAGS_DEBUG "-g")
+ if(ENABLE_GCC_OPTIMIZATION)
+ set(CMAKE_BUILD_TYPE Release)
+ set(CMAKE_CXX_FLAGS_RELEASE "${CMAKE_CXX_FLAGS} -DNDEBUG -Os -Wno-strict-aliasing -Wl,-O1")
+ if(NOT CMAKE_HOST_APPLE)
+ set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -Wl,--hash-style=gnu")
+ endif()
+ endif()
+endif()
+
+if(NOT CMAKE_BUILD_TYPE)
+ set(CMAKE_BUILD_TYPE Release)
+endif()
+
set(LIB_SUFFIX "" CACHE STRING "Define suffix of directory name (32/64)" )
set(LIB_INSTALL_DIR "${CMAKE_INSTALL_PREFIX}/lib${LIB_SUFFIX}" CACHE PATH "The subdirectory relative to the install prefix where libraries will be installed (default is /lib${LIB_SUFFIX})" FORCE)