-
Notifications
You must be signed in to change notification settings - Fork 1
/
Copy pathCMakeLists.txt
82 lines (69 loc) · 2.53 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
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
cmake_minimum_required(VERSION 3.12)
project(FMLearn)
set(CMAKE_CXX_STANDARD 11)
set(DEBUG_GDB ON)
if(${DEBUG_GDB} STREQUAL "ON")
set(CMAKE_BUILD_TYPE DEBUG)
set(CMAKE_CXX_FLAGS_DEBUG "$ENV{CXXFLAGS} -O0 -Wall -g -ggdb")
else ()
set(CMAKE_BUILD_TYPE RELEASE)
add_definitions("-O3")
endif ()
if (WIN32)
#Windows
if (MSVC)
# 为VS2017设置参数
if (NOT "${CMAKE_GENERATOR}" MATCHES "(Wino64|IA64)")
else ()
# set(CMAKE_GENERATOR_PLATFORM "Visual Studio 15 2017 Win64")
set(CMAKE_VS_PLATFORM_TOOLSET_HOST_ARCHITECTURE, "host=x64")
add_definitions("/WX- /MD")
endif ()
endif ()
set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -D__FILENAME__=__FILE__")
else ()
#Linux
set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -D__FILENAME__='\"$(subst ${CMAKE_SOURCE_DIR}/src/,,$(abspath $<))\"'")
add_definitions("-Wall -Wno-sign-compare -march=native -Wno-strict-aliasing -Wno-comment")
endif ()
# 保存编译结果的目录
set(BUILD_RESULT_DIR ${PROJECT_BINARY_DIR}/results/)
include_directories(
"${PROJECT_SOURCE_DIR}/src"
"${PROJECT_BINARY_DIR}"
"${PROJECT_SOURCE_DIR}/gtest/include"
)
link_directories(
"${PROJECT_BINARY_DIR}/src/common"
"${PROJECT_BINARY_DIR}/src/data"
"${PROJECT_BINARY_DIR}/src/loss"
"${PROJECT_BINARY_DIR}/src/score"
"${PROJECT_BINARY_DIR}/src/core"
"${PROJECT_BINARY_DIR}/src/metric"
"${PROJECT_BINARY_DIR}/src/c_api"
"${PROJECT_BINARY_DIR}/src/cli"
)
add_subdirectory(gtest)
add_subdirectory(src/common)
add_subdirectory(src/data)
add_subdirectory(src/loss)
add_subdirectory(src/score)
add_subdirectory(src/solver)
add_subdirectory(src/metric)
add_subdirectory(src/cli)
add_subdirectory(src/model)
add_subdirectory(src/c_api)
# 拷贝测试脚本与测试数据
if (WIN32)
FILE(COPY "${PROJECT_SOURCE_DIR}/scripts/run_test.bat" DESTINATION ${BUILD_RESULT_DIR})
else ()
FILE(COPY "${PROJECT_SOURCE_DIR}/scripts/run_test.sh" DESTINATION ${BUILD_RESULT_DIR})
endif ()
FILE(COPY "${PROJECT_SOURCE_DIR}/python-package/fmlearn/house_price_train.txt"
DESTINATION ${BUILD_RESULT_DIR}/data)
FILE(COPY "${PROJECT_SOURCE_DIR}/python-package/fmlearn/house_price_valid.txt"
DESTINATION ${BUILD_RESULT_DIR}/data)
FILE(COPY "${PROJECT_SOURCE_DIR}/python-package/fmlearn/house_price_test.txt"
DESTINATION ${BUILD_RESULT_DIR}/data)
file(GLOB HEADER_FILES "${PROJECT_SOURCE_DIR}/src/*/*.h")
install(FILES ${HEADER_FILES} DESTINATION ${BUILD_RESULT_DIR}/include)