Pascal Bach | d5f87e1 | 2014-12-12 15:59:17 +0100 | [diff] [blame] | 1 | # |
| 2 | # Licensed to the Apache Software Foundation (ASF) under one |
| 3 | # or more contributor license agreements. See the NOTICE file |
| 4 | # distributed with this work for additional information |
| 5 | # regarding copyright ownership. The ASF licenses this file |
| 6 | # to you under the Apache License, Version 2.0 (the |
| 7 | # "License"); you may not use this file except in compliance |
| 8 | # with the License. You may obtain a copy of the License at |
| 9 | # |
| 10 | # http://www.apache.org/licenses/LICENSE-2.0 |
| 11 | # |
| 12 | # Unless required by applicable law or agreed to in writing, |
| 13 | # software distributed under the License is distributed on an |
| 14 | # "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY |
| 15 | # KIND, either express or implied. See the License for the |
| 16 | # specific language governing permissions and limitations |
| 17 | # under the License. |
| 18 | # |
| 19 | |
| 20 | |
| 21 | # Visual Studio specific options |
| 22 | if(MSVC) |
| 23 | #For visual studio the library naming is as following: |
| 24 | # Dynamic libraries: |
Jim King | 9de9b1f | 2015-04-30 16:03:34 -0400 | [diff] [blame] | 25 | # - thrift.dll for release library |
Pascal Bach | d5f87e1 | 2014-12-12 15:59:17 +0100 | [diff] [blame] | 26 | # - thriftd.dll for debug library |
| 27 | # |
| 28 | # Static libraries: |
| 29 | # - thriftmd.lib for /MD release build |
| 30 | # - thriftmt.lib for /MT release build |
| 31 | # |
| 32 | # - thriftmdd.lib for /MD debug build |
| 33 | # - thriftmtd.lib for /MT debug build |
| 34 | # |
| 35 | # the same holds for other libraries like libthriftz etc. |
| 36 | |
| 37 | # For Debug build types, append a "d" to the library names. |
| 38 | set(CMAKE_DEBUG_POSTFIX "d" CACHE STRING "Set debug library postfix" FORCE) |
| 39 | set(CMAKE_RELEASE_POSTFIX "" CACHE STRING "Set release library postfix" FORCE) |
| 40 | |
Pascal Bach | d5f87e1 | 2014-12-12 15:59:17 +0100 | [diff] [blame] | 41 | # Build using /MT option instead of /MD if the WITH_MT options is set |
| 42 | if(WITH_MT) |
| 43 | set(CompilerFlags |
| 44 | CMAKE_CXX_FLAGS |
| 45 | CMAKE_CXX_FLAGS_DEBUG |
| 46 | CMAKE_CXX_FLAGS_RELEASE |
| 47 | CMAKE_C_FLAGS |
| 48 | CMAKE_C_FLAGS_DEBUG |
| 49 | CMAKE_C_FLAGS_RELEASE |
| 50 | ) |
| 51 | foreach(CompilerFlag ${CompilerFlags}) |
| 52 | string(REPLACE "/MD" "/MT" ${CompilerFlag} "${${CompilerFlag}}") |
| 53 | endforeach() |
| 54 | set(STATIC_POSTFIX "mt" CACHE STRING "Set static library postfix" FORCE) |
| 55 | else(WITH_MT) |
| 56 | set(STATIC_POSTFIX "md" CACHE STRING "Set static library postfix" FORCE) |
| 57 | endif(WITH_MT) |
Jim King | 1673adf | 2015-04-13 12:25:35 -0400 | [diff] [blame] | 58 | |
Jim King | 9de9b1f | 2015-04-30 16:03:34 -0400 | [diff] [blame] | 59 | # Disable Windows.h definition of macros for min and max |
| 60 | add_definitions("-DNOMINMAX") |
| 61 | |
| 62 | # Disable boost auto linking pragmas - cmake includes the right files |
| 63 | add_definitions("-DBOOST_ALL_NO_LIB") |
| 64 | |
| 65 | # Windows build does not know how to make a shared library yet |
| 66 | # as there are no __declspec(dllexport) or exports files in the project. |
| 67 | if (WITH_SHARED_LIB) |
| 68 | message (FATAL_ERROR "Windows build does not support shared library output yet!") |
| 69 | endif() |
| 70 | |
Jim King | 1673adf | 2015-04-13 12:25:35 -0400 | [diff] [blame] | 71 | elseif(UNIX) |
| 72 | # For UNIX |
| 73 | # WITH_*THREADS selects which threading library to use |
| 74 | if(WITH_BOOSTTHREADS) |
| 75 | add_definitions("-DUSE_BOOST_THREAD=1") |
| 76 | elseif(WITH_STDTHREADS) |
| 77 | add_definitions("-DUSE_STD_THREAD=1") |
| 78 | endif() |
| 79 | |
Roger Meier | 446a319 | 2015-05-09 23:40:54 +0200 | [diff] [blame] | 80 | find_program( MEMORYCHECK_COMMAND valgrind ) |
| 81 | set( MEMORYCHECK_COMMAND_OPTIONS "--gen-suppressions=all --leak-check=full" ) |
| 82 | set( MEMORYCHECK_SUPPRESSIONS_FILE "${PROJECT_SOURCE_DIR}/test/valgrind.suppress" ) |
Jim King | 1673adf | 2015-04-13 12:25:35 -0400 | [diff] [blame] | 83 | endif() |
Pascal Bach | d5f87e1 | 2014-12-12 15:59:17 +0100 | [diff] [blame] | 84 | |
Marco Molteni | 8349425 | 2015-04-16 13:50:20 +0200 | [diff] [blame] | 85 | # GCC and Clang. |
| 86 | if(CMAKE_COMPILER_IS_GNUCC OR CMAKE_COMPILER_IS_GNUCXX OR CMAKE_CXX_COMPILER_ID MATCHES "Clang") |
| 87 | # FIXME -pedantic can not be used at the moment because of: https://issues.apache.org/jira/browse/THRIFT-2784 |
Pascal Bach | d5f87e1 | 2014-12-12 15:59:17 +0100 | [diff] [blame] | 88 | #set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -std=c++11 -O2 -Wall -Wextra -pedantic") |
Marco Molteni | 8349425 | 2015-04-16 13:50:20 +0200 | [diff] [blame] | 89 | # FIXME enabling c++11 breaks some Linux builds on Travis by triggering a g++ bug, see |
| 90 | # https://travis-ci.org/apache/thrift/jobs/58017022 |
| 91 | # on the other hand, both MacOSX and FreeBSD need c++11 |
| 92 | if(${CMAKE_SYSTEM_NAME} MATCHES "Darwin" OR ${CMAKE_SYSTEM_NAME} MATCHES "FreeBSD") |
| 93 | set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -std=c++11 -O2 -Wall -Wextra") |
| 94 | endif() |
Pascal Bach | d5f87e1 | 2014-12-12 15:59:17 +0100 | [diff] [blame] | 95 | endif() |