comparison Orthanc/Resources/CMake/Compiler.cmake @ 28:d158e4ca5734

sync with mainline
author Sebastien Jodogne <s.jodogne@gmail.com>
date Thu, 04 Jun 2015 09:54:10 +0200
parents 15acbf5e7545
children 111689a2c177
comparison
equal deleted inserted replaced
27:c05ce507d8ae 28:d158e4ca5734
1 # This file sets all the compiler-related flags 1 # This file sets all the compiler-related flags
2 2
3 if (${CMAKE_COMPILER_IS_GNUCXX}) 3 if (CMAKE_CROSSCOMPILING)
4 # Cross-compilation necessarily implies standalone and static build
5 SET(STATIC_BUILD ON)
6 SET(STANDALONE_BUILD ON)
7 endif()
8
9 if (CMAKE_COMPILER_IS_GNUCXX)
4 set(CMAKE_C_FLAGS "${CMAKE_C_FLAGS} -Wall -Wno-long-long -Wno-implicit-function-declaration") 10 set(CMAKE_C_FLAGS "${CMAKE_C_FLAGS} -Wall -Wno-long-long -Wno-implicit-function-declaration")
5 # --std=c99 makes libcurl not to compile 11 # --std=c99 makes libcurl not to compile
6 # -pedantic gives a lot of warnings on OpenSSL 12 # -pedantic gives a lot of warnings on OpenSSL
7 set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -Wall -pedantic -Wno-long-long -Wno-variadic-macros") 13 set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -Wall -pedantic -Wno-long-long -Wno-variadic-macros")
8 14
9 if (CMAKE_CROSSCOMPILING) 15 if (CMAKE_CROSSCOMPILING)
10 # http://stackoverflow.com/a/3543845/881731 16 # http://stackoverflow.com/a/3543845/881731
11 set(CMAKE_RC_COMPILE_OBJECT "<CMAKE_RC_COMPILER> -O coff -I<CMAKE_CURRENT_SOURCE_DIR> <SOURCE> <OBJECT>") 17 set(CMAKE_RC_COMPILE_OBJECT "<CMAKE_RC_COMPILER> -O coff -I<CMAKE_CURRENT_SOURCE_DIR> <SOURCE> <OBJECT>")
12 endif() 18 endif()
13 19
14 elseif (${MSVC}) 20 elseif (MSVC)
15 # Use static runtime under Visual Studio 21 # Use static runtime under Visual Studio
16 # http://www.cmake.org/Wiki/CMake_FAQ#Dynamic_Replace 22 # http://www.cmake.org/Wiki/CMake_FAQ#Dynamic_Replace
17 # http://stackoverflow.com/a/6510446 23 # http://stackoverflow.com/a/6510446
18 foreach(flag_var 24 foreach(flag_var
19 CMAKE_C_FLAGS_DEBUG 25 CMAKE_C_FLAGS_DEBUG
51 set(CMAKE_SHARED_LIBRARY_LINK_CXX_FLAGS "") 57 set(CMAKE_SHARED_LIBRARY_LINK_CXX_FLAGS "")
52 link_libraries(uuid pthread rt) 58 link_libraries(uuid pthread rt)
53 59
54 if (NOT ${CMAKE_SYSTEM_NAME} STREQUAL "FreeBSD") 60 if (NOT ${CMAKE_SYSTEM_NAME} STREQUAL "FreeBSD")
55 set(CMAKE_EXE_LINKER_FLAGS "${CMAKE_EXE_LINKER_FLAGS} -Wl,--as-needed") 61 set(CMAKE_EXE_LINKER_FLAGS "${CMAKE_EXE_LINKER_FLAGS} -Wl,--as-needed")
62 set(CMAKE_MODULE_LINKER_FLAGS "${CMAKE_MODULE_LINKER_FLAGS} -Wl,--as-needed")
63 set(CMAKE_SHARED_LINKER_FLAGS "${CMAKE_SHARED_LINKER_FLAGS} -Wl,--as-needed")
56 add_definitions( 64 add_definitions(
57 -D_LARGEFILE64_SOURCE=1 65 -D_LARGEFILE64_SOURCE=1
58 -D_FILE_OFFSET_BITS=64 66 -D_FILE_OFFSET_BITS=64
59 ) 67 )
60 link_libraries(dl) 68 link_libraries(dl)
65 -DWINVER=0x0501 73 -DWINVER=0x0501
66 -D_CRT_SECURE_NO_WARNINGS=1 74 -D_CRT_SECURE_NO_WARNINGS=1
67 ) 75 )
68 link_libraries(rpcrt4 ws2_32) 76 link_libraries(rpcrt4 ws2_32)
69 77
70 if (${CMAKE_COMPILER_IS_GNUCXX}) 78 if (CMAKE_COMPILER_IS_GNUCXX)
71 # This is a patch for MinGW64 79 # This is a patch for MinGW64
72 SET(CMAKE_EXE_LINKER_FLAGS "${CMAKE_SHARED_LINKER_FLAGS} -Wl,--allow-multiple-definition -static-libgcc -static-libstdc++") 80 SET(CMAKE_EXE_LINKER_FLAGS "${CMAKE_SHARED_LINKER_FLAGS} -Wl,--allow-multiple-definition -static-libgcc -static-libstdc++")
73 81
74 CHECK_LIBRARY_EXISTS(winpthread pthread_create "" HAVE_WIN_PTHREAD) 82 CHECK_LIBRARY_EXISTS(winpthread pthread_create "" HAVE_WIN_PTHREAD)
75 if (HAVE_WIN_PTHREAD) 83 if (HAVE_WIN_PTHREAD)
116 if (NOT HAVE_UUID_H) 124 if (NOT HAVE_UUID_H)
117 message(FATAL_ERROR "Please install the uuid-dev package") 125 message(FATAL_ERROR "Please install the uuid-dev package")
118 endif() 126 endif()
119 127
120 128
121 if (${STATIC_BUILD}) 129 if (STATIC_BUILD)
122 add_definitions(-DORTHANC_STATIC=1) 130 add_definitions(-DORTHANC_STATIC=1)
123 else() 131 else()
124 add_definitions(-DORTHANC_STATIC=0) 132 add_definitions(-DORTHANC_STATIC=0)
125 endif() 133 endif()