-
Notifications
You must be signed in to change notification settings - Fork 8
/
CMakeLists.txt
55 lines (48 loc) · 2.62 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
41
42
43
44
45
46
47
48
49
50
51
52
53
54
cmake_minimum_required(VERSION 3.0)
project(LHS)
set(CMAKE_VERBOSE_MAKEFILE on)
set(CMAKE_SOURCE_DIR "src")
file(GLOB lhs_soures "src/*.cpp")
add_library(lhs SHARED ${lhs_soures})
if (MSVC)
include_directories("C:/Users/bertc/Documents/R/win-library/3.5/Rcpp/include")
include_directories("C:/Program Files/R/R-3.5.1/include")
#find_library(R_LIBRARY R PATHS "C:/Program Files/R/R-3.5.1/bin/x64" NO_DEFAULT_PATH)
set(R_LIBRARY "C:/Program Files/R/R-3.5.1/bin/x64/R.dll")
target_link_libraries(lhs PUBLIC ${R_LIBRARY})
# disable unreferenced formal parameters (4100) and constant conditional expression (4127) and special noexcept from asserterror (26439) and not initialized variables (26495)
set(CMAKE_CXX_FLAGS "/EHsc /W4 /WX /wd4100 /wd4127 /wd26439 /wd26495")
set(CMAKE_CXX_FLAGS_DEBUG "/Od /Zi")
set(CMAKE_CXX_FLAGS_RELEASE "/Ox")
set(CMAKE_CXX_FLAGS_RELWITHDEBINFO "/O2 /Zi")
elseif (CMAKE_CXX_COMPILER_ID MATCHES "GNU" AND CMAKE_SYSTEM_NAME MATCHES "Linux")
include_directories("/usr/share/R/include")
include_directories("/usr/local/lib/R/site-library/Rcpp/include")
find_library(R_LIBRARY R HINTS "/usr/lib/R/lib")
target_link_libraries(lhs PUBLIC ${R_LIBRARY})
set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -std=c++11 -m64 -Wall -pedantic -mtune=native -Werror -Wno-unknown-pragmas -Wno-long-long")
set(CMAKE_CXX_FLAGS_DEBUG "${CMAKE_CXX_FLAGS} -g -O0")
set(CMAKE_CXX_FLAGS_RELEASE "${CMAKE_CXX_FLAGS} -O3")
set(CMAKE_CXX_FLAGS_RELWITHDEBINFO "${CMAKE_CXX_FLAGS} -O2 -g")
else ()
include_directories("C:/Users/bertc/Documents/R/win-library/3.5/Rcpp/include")
include_directories("C:/Program Files/R/R-3.5.1/include")
find_library(R_LIBRARY R HINTS "C:/Program Files/R/R-3.5.1/bin/x64")
target_link_libraries(lhs PUBLIC ${R_LIBRARY})
set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -std=c++11 -m64 -Wall -pedantic -mtune=native -Werror -Wno-unknown-pragmas -Wno-long-long")
set(CMAKE_CXX_FLAGS_DEBUG "${CMAKE_CXX_FLAGS} -g -O0")
set(CMAKE_CXX_FLAGS_RELEASE "${CMAKE_CXX_FLAGS} -O3")
set(CMAKE_CXX_FLAGS_RELWITHDEBINFO "${CMAKE_CXX_FLAGS} -O2 -g")
endif ()
if (CMAKE_BUILD_TYPE STREQUAL "Coverage")
set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -g -O0 -fprofile-arcs -ftest-coverage")
set(CMAKE_EXE_LINKER_FLAGS "${CMAKE_EXE_LINKER_FLAGS} -lgcov")
message(STATUS "CXXFLAGS: ${CMAKE_CXX_FLAGS}")
elseif (CMAKE_BUILD_TYPE STREQUAL "Debug")
message(STATUS "Debug CXXFLAGS: ${CMAKE_CXX_FLAGS_DEBUG}")
elseif (CMAKE_BUILD_TYPE STREQUAL "Release")
message(STATUS "Release CXXFLAGS: ${CMAKE_CXX_FLAGS_RELEASE}")
else()
message(STATUS "CXXFLAGS: ${CMAKE_CXX_FLAGS}")
endif()
message(STATUS "Linker FLAGS: ${CMAKE_EXE_LINKER_FLAGS}")