-
Notifications
You must be signed in to change notification settings - Fork 8
/
Copy pathCMakeLists.txt
40 lines (34 loc) · 1.31 KB
/
CMakeLists.txt
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
project(whook)
cmake_minimum_required(VERSION 2.8)
set(CMAKE_RUNTIME_OUTPUT_DIRECTORY ${PROJECT_BINARY_DIR}/bin)
macro(replace_flags var these those)
if ("${${var}}" MATCHES "${these}")
string(REGEX REPLACE "${these}" "${those}" ${var} "${${var}}")
message(STATUS "info: ${var} changed to '${${var}}'")
endif()
message(STATUS "info: ${var}='${${var}}'")
endmacro()
macro(msvc_link_to_static_crt)
if (MSVC)
set(has_correct_flag 0)
foreach(lang C CXX)
foreach(suffix "" _DEBUG _MINSIZEREL _RELEASE _RELWITHDEBINFO)
replace_flags("CMAKE_${lang}_FLAGS${suffix}" "/MD" "/MT")
endforeach()
endforeach()
endif()
endmacro()
add_definitions(-DWINDOWS)
foreach(lang C CXX)
if ("${CMAKE_${lang}_FLAGS}" MATCHES "/W[1-3]")
string(REGEX REPLACE "/W[1-3]" "/W4 /WX" CMAKE_${lang}_FLAGS "${CMAKE_${lang}_FLAGS}")
message(STATUS "Replacing /W[1-3] with /W4 /WX...")
else ("${CMAKE_${lang}_FLAGS}" MATCHES "/W[1-3]")
set(CMAKE_${lang}_FLAGS "${CMAKE_${lang}_FLAGS} /W4 /WX")
message(STATUS "Adding /W4 /WX...")
endif ("${CMAKE_${lang}_FLAGS}" MATCHES "/W[1-3]")
endforeach(lang)
msvc_link_to_static_crt()
SET(LINK_LIBS ${LINK_LIBS} ws2_32.lib iphlpapi.lib)
add_subdirectory(src/)
add_subdirectory(test/)