forked from colinfang/lbfgsb_cpp
-
Notifications
You must be signed in to change notification settings - Fork 1
/
CMakeLists.txt
73 lines (62 loc) · 2.37 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
cmake_minimum_required(VERSION 3.10)
project(lbfgsb_cpp)
enable_language(C CXX)
set(CMAKE_CXX_STANDARD 17)
option(BUILD_EXAMPLE "Build example" OFF)
set(HEADERS "include/${PROJECT_NAME}/lbfgsb.hpp")
add_library(${PROJECT_NAME} Lbfgsb.3.0/include/lbfgsb/lbfgsb.h
Lbfgsb.3.0/blas.c
Lbfgsb.3.0/lbfgsb.c
Lbfgsb.3.0/linpack.c
Lbfgsb.3.0/s_cmp.c
Lbfgsb.3.0/s_copy.c
Lbfgsb.3.0/timer.c
)
add_library(${PROJECT_NAME}::${PROJECT_NAME} ALIAS ${PROJECT_NAME})
set(EMBED_CUSTOM_BLAS ON)
#if (TARGET blas)
# set(EMBED_CUSTOM_BLAS OFF)
# # target_link_libraries(${PROJECT_NAME} INTERFACE blas)
#endif ()
if (EMBED_CUSTOM_BLAS)
# to avoid collision with outer blas
# short rename to avoid truncate code interpretation after column #72
target_compile_definitions(${PROJECT_NAME} PRIVATE dcopy_=Wcopy_)
target_compile_definitions(${PROJECT_NAME} PRIVATE dscal_=Wscal_)
target_compile_definitions(${PROJECT_NAME} PRIVATE daxpy_=Waxpy_)
target_compile_definitions(${PROJECT_NAME} PRIVATE dnrm2_=Wnrm2_)
target_compile_definitions(${PROJECT_NAME} PRIVATE ddot_=Wdot_)
endif ()
target_include_directories(
${PROJECT_NAME} INTERFACE
$<BUILD_INTERFACE:${CMAKE_CURRENT_SOURCE_DIR}/include>
$<INSTALL_INTERFACE:include>
)
target_compile_features(${PROJECT_NAME} INTERFACE cxx_std_11)
if (CMAKE_BUILD_TYPE MATCHES "Release")
# Nothing to do
else ()
# target_compile_options(${PROJECT_NAME} PRIVATE -fcheck=all)
endif ()
if (BUILD_EXAMPLE)
enable_testing()
add_subdirectory(examples)
endif ()
# Create install rule for your library. Use variables CMAKE_INSTALL_*DIR defined in GNUInstallDir
include(GNUInstallDirs)
# https://cmake.org/cmake/help/latest/command/install.html
# https://pabloariasal.github.io/2018/02/19/its-time-to-do-cmake-right/
install(TARGETS ${PROJECT_NAME}
EXPORT ${PROJECT_NAME}_targets
LIBRARY DESTINATION ${CMAKE_INSTALL_LIBDIR}
ARCHIVE DESTINATION ${CMAKE_INSTALL_LIBDIR} COMPONENT devel
RUNTIME DESTINATION ${CMAKE_INSTALL_BINDIR} COMPONENT runtime
PUBLIC_HEADER DESTINATION ${CMAKE_INSTALL_INCLUDEDIR} COMPONENT devel
)
install(FILES ${HEADERS} DESTINATION "include/${PROJECT_NAME}")
install(
EXPORT ${PROJECT_NAME}_targets
FILE ${PROJECT_NAME}Config.cmake
NAMESPACE ${PROJECT_NAME}::
DESTINATION lib/cmake/${PROJECT_NAME}
)