aboutsummaryrefslogtreecommitdiff
path: root/CMakeLists.txt
diff options
context:
space:
mode:
authorRiccardo Spagni <ric@spagni.net>2016-09-18 11:44:08 +0200
committerRiccardo Spagni <ric@spagni.net>2016-09-18 11:44:08 +0200
commit4a03a8a1da1341fcceeb8a73a24ea1b4cedb443c (patch)
treeae9b02dcb8c241b719e0f8ea7c4ef3fe991b9f3a /CMakeLists.txt
parentMerge pull request #1093 (diff)
parentcmake: support BUILD_SHARED_LIBS built-in option (diff)
downloadmonero-4a03a8a1da1341fcceeb8a73a24ea1b4cedb443c.tar.xz
Merge pull request #1094
06bb692 cmake: support BUILD_SHARED_LIBS built-in option (redfish) e1c7af3 cmake: transitive deps and remove deprecated LINK_* (redfish) 54010b9 crypto: armv7: slow-hash: remove redundant source include (redfish)
Diffstat (limited to 'CMakeLists.txt')
-rw-r--r--CMakeLists.txt16
1 files changed, 14 insertions, 2 deletions
diff --git a/CMakeLists.txt b/CMakeLists.txt
index ca600935d..2761b32f7 100644
--- a/CMakeLists.txt
+++ b/CMakeLists.txt
@@ -49,6 +49,7 @@ if(NOT CMAKE_BUILD_TYPE)
set(CMAKE_BUILD_TYPE Release CACHE STRING "Build type" FORCE)
message(STATUS "Setting default build type: ${CMAKE_BUILD_TYPE}")
endif()
+string(TOLOWER ${CMAKE_BUILD_TYPE} CMAKE_BUILD_TYPE_LOWER)
# ARCH defines the target architecture, either by an explicit identifier or
# one of the following two keywords. By default, ARCH a value of 'native':
@@ -179,6 +180,17 @@ else()
endif()
option(STATIC "Link libraries statically" ${DEFAULT_STATIC})
+# This is a CMake built-in switch that concerns internal libraries
+if (NOT DEFINED BUILD_SHARED_LIBS AND NOT STATIC AND CMAKE_BUILD_TYPE_LOWER STREQUAL "debug")
+ set(BUILD_SHARED_LIBS ON CACHE STRING "Build internal libs as shared")
+endif()
+if (BUILD_SHARED_LIBS)
+ message(STATUS "Building internal libraries as shared")
+ set(PIC_FLAG "-fPIC")
+else()
+ message(STATUS "Building internal libraries as static")
+endif()
+
if(MINGW)
string(REGEX MATCH "^[^/]:/[^/]*" msys2_install_path "${CMAKE_C_COMPILER}")
message(STATUS "MSYS location: ${msys2_install_path}")
@@ -365,8 +377,8 @@ else()
set(COVERAGE_FLAGS "-fprofile-arcs -ftest-coverage --coverage")
endif()
- set(CMAKE_C_FLAGS "${CMAKE_C_FLAGS} -std=c11 -D_GNU_SOURCE ${MINGW_FLAG} ${STATIC_ASSERT_FLAG} ${WARNINGS} ${C_WARNINGS} ${ARCH_FLAG} ${COVERAGE_FLAGS}")
- set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -std=c++11 -D_GNU_SOURCE ${MINGW_FLAG} ${WARNINGS} ${CXX_WARNINGS} ${ARCH_FLAG} ${COVERAGE_FLAGS}")
+ set(CMAKE_C_FLAGS "${CMAKE_C_FLAGS} -std=c11 -D_GNU_SOURCE ${MINGW_FLAG} ${STATIC_ASSERT_FLAG} ${WARNINGS} ${C_WARNINGS} ${ARCH_FLAG} ${COVERAGE_FLAGS} ${PIC_FLAG}")
+ set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -std=c++11 -D_GNU_SOURCE ${MINGW_FLAG} ${WARNINGS} ${CXX_WARNINGS} ${ARCH_FLAG} ${COVERAGE_FLAGS} ${PIC_FLAG}")
# With GCC 6.1.1 the compiled binary malfunctions due to aliasing. Until that
# is fixed in the code (Issue #847), force compiler to be conservative.