Skip to content

Commit 3c20bd1

Browse files
committed
Updated to the latest version
1 parent e4fe691 commit 3c20bd1

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

91 files changed

+7866
-5718
lines changed

gurls++/CMakeLists.txt

Lines changed: 130 additions & 125 deletions
Original file line numberDiff line numberDiff line change
@@ -1,192 +1,197 @@
1-
#
2-
# Copyright (C) 2012 Matteo Santoro
3-
# CopyPolicy: Released under the terms of GPL
4-
#
1+
cmake_minimum_required(VERSION 2.6)
52

63
project(gurls++)
74

8-
set(GURLSLIBRARY gurls++)
9-
set(SRCDIR src/)
10-
set(HDRDIR include/)
11-
set(TUTORIALDIR tutorial/)
12-
set(TESTDIR test/)
5+
set(CMAKE_MODULE_PATH ${CMAKE_CURRENT_SOURCE_DIR} ${CMAKE_MODULE_PATH})
136

14-
set(gurls_headers "")
157

16-
set(gurls_sources
17-
${SRCDIR}gmath.cpp
18-
${SRCDIR}options.cpp
19-
${SRCDIR}optlist.cpp
20-
)
8+
if(CMAKE_COMPILER_IS_GNUCC OR MSVC)
219

22-
set(USE_CUDA OFF CACHE BOOL "")
10+
set(BLAS_LAPACK_IMPLEMENTATION "" CACHE STRING "Specify your blas/lapack implementation (MKL, ACML, ATLAS, NETLIB or an empty string)")
2311

24-
if(USE_CUDA)
12+
if(BLAS_LAPACK_IMPLEMENTATION STREQUAL "MKL")
2513

26-
set(CMAKE_MODULE_PATH "${CMAKE_SOURCE_DIR}/CMake/cuda" ${CMAKE_MODULE_PATH})
14+
unset(BLAS_LIBRARIES CACHE)
15+
unset(LAPACK_LIBRARIES CACHE)
2716

28-
find_package(CUDA QUIET REQUIRED)
17+
find_package(MKL)
2918

30-
if(NOT CUDA_FOUND)
31-
message("CUDA could not be located on your system.")
32-
endif(NOT CUDA_FOUND)
19+
include_directories(${MKL_INCLUDE_DIRS})
20+
link_directories(${MKL_LIBRARY_DIRS})
21+
add_definitions( ${MKL_DEFINITIONS})
3322

34-
set(gurls_sources
35-
${gurls_sources}
36-
${SRCDIR}gmath_gpu.cpp
37-
)
23+
set(BLAS_LIBRARIES "")
24+
set(LAPACK_LIBRARIES ${MKL_LIBRARIES})
3825

39-
set(GPULIBRARY ${CUDA_LIBRARIES} ${CUDA_CUBLAS_LIBRARIES})
26+
elseif(BLAS_LAPACK_IMPLEMENTATION STREQUAL "ACML")
4027

41-
else(USE_CUDA)
42-
set(GPULIBRARY "")
43-
endif(USE_CUDA)
28+
unset(BLAS_LIBRARIES CACHE)
29+
unset(LAPACK_LIBRARIES CACHE)
4430

31+
find_package(ACML)
32+
set(BLAS_LIBRARIES "")
33+
add_definitions( ${ACML_DEFINITIONS})
34+
set(LAPACK_LIBRARIES ${ACML_LIBRARIES})
4535

46-
set(Boost_USE_MULTITHREADED ON)
47-
set(Boost_USE_STATIC_RUNTIME OFF)
48-
find_package( Boost COMPONENTS serialization date_time REQUIRED)
49-
OPTION(Boost_USE_STATIC_LIBS "Link statically to boost libs" OFF)
5036

51-
if(Boost_FOUND)
52-
include_directories(${Boost_INCLUDE_DIRS})
53-
link_directories(${Boost_LIBRARY_DIRS})
54-
endif(Boost_FOUND)
37+
elseif(BLAS_LAPACK_IMPLEMENTATION STREQUAL "ATLAS")
5538

56-
include_directories(
57-
${HDRDIR}
58-
)
39+
unset(BLAS_LIBRARIES CACHE)
40+
unset(LAPACK_LIBRARIES CACHE)
5941

60-
set(USE_BINARY_ARCHIVES OFF CACHE BOOL "If ON all the data structures in GURLS are saved/loaded using binary files.")
42+
find_package(ATLAS)
43+
set(BLAS_LIBRARIES ${ATLAS_BLAS_LIBS} ${ATLAS_LIBS} gfortran)
44+
add_definitions( ${ATLAS_DEFINITIONS})
45+
set(LAPACK_LIBRARIES ${ATLAS_LAPACK_LIBS})
6146

62-
if(USE_BINARY_ARCHIVES)
63-
add_definitions(-DUSE_BINARY_ARCHIVES)
64-
endif(USE_BINARY_ARCHIVES)
47+
elseif(BLAS_LAPACK_IMPLEMENTATION STREQUAL "NETLIB")
6548

49+
unset(BLAS_LIBRARIES CACHE)
50+
unset(LAPACK_LIBRARIES CACHE)
6651

67-
set(USE_MKL OFF CACHE BOOL "")
52+
enable_language(Fortran)
53+
find_package(BLAS)
54+
find_package(LAPACK)
6855

69-
if(USE_MKL)
56+
else(BLAS_LAPACK_IMPLEMENTATION STREQUAL "MKL")
7057

71-
SET(MKL_ARCH "em64t" CACHE STRING "System architecture (32, 64, em64t)")
72-
SET(MKLROOT "" CACHE PATH "Path to MKL")
58+
set(BLAS_LIBRARIES "" CACHE FILEPATH "")
59+
set(LAPACK_LIBRARIES "" CACHE FILEPATH "")
7360

74-
SET(MKL_LIB_PATH ${MKLROOT}/lib/${MKL_ARCH})
61+
endif(BLAS_LAPACK_IMPLEMENTATION STREQUAL "MKL")
7562

76-
include_directories(${MKLROOT}/include)
77-
include_directories(${MKL_LIB_PATH})
63+
else(CMAKE_COMPILER_IS_GNUCC OR MSVC)
7864

79-
if(variable STREQUAL "32")
80-
SET(ARCH_PREFIX "")
81-
else(variable STREQUAL "32")
82-
SET(ARCH_PREFIX "_lp64")
83-
endif(variable STREQUAL "32")
65+
set(BLAS_LIBRARIES "" CACHE FILEPATH "")
66+
set(LAPACK_LIBRARIES "" CACHE FILEPATH "")
8467

85-
SET(BLAS_LIBRARIES "")
68+
endif(CMAKE_COMPILER_IS_GNUCC OR MSVC)
8669

87-
SET(LAPACK_LIBRARIES
88-
${MKL_LIB_PATH}/libmkl_scalapack${ARCH_PREFIX}.a
89-
${MKL_LIB_PATH}/libmkl_solver${ARCH_PREFIX}.a
90-
-Wl,--start-group
91-
${MKL_LIB_PATH}/libmkl_intel${ARCH_PREFIX}.a
92-
${MKL_LIB_PATH}/libmkl_gnu_thread.a
93-
${MKL_LIB_PATH}/libmkl_core.a
94-
${MKL_LIB_PATH}/libmkl_blacs_openmpi${ARCH_PREFIX}.a
95-
-Wl,--end-group -fopenmp -lpthread -lm
96-
)
9770

98-
# SET(LAPACK_LIBRARIES
99-
# ${MKL_LIB_PATH}/libmkl_solver_lp64_sequential.a -Wl,--start-group ${MKL_LIB_PATH}/libmkl_intel_lp64.a ${MKL_LIB_PATH}/libmkl_sequential.a ${MKL_LIB_PATH}/libmkl_core.a -Wl,--end-group -lpthread -lm
100-
# )
71+
set(GURLSLIBRARY gurls++)
72+
set(SRCDIR src/)
73+
set(HDRDIR include/)
74+
set(DEMODIR demo/)
75+
set(TESTDIR test/)
76+
77+
78+
function(add_all_executables ROOTDIR SRCDIR LINK_LIBS)
79+
80+
file(GLOB sources RELATIVE ${ROOTDIR} ${SRCDIR}*.cpp)
10181

102-
endif(USE_MKL)
82+
set(executables "")
10383

104-
set(USE_ACML OFF CACHE BOOL "")
105-
if(USE_ACML)
84+
foreach(source_file ${sources})
10685

107-
SET(ACMLROOT "" CACHE PATH "Path to ACML")
86+
string(REGEX REPLACE ".cpp" "" executable ${source_file})
87+
string(REGEX REPLACE ${SRCDIR} "" executable ${executable})
10888

109-
SET(ACML_LIB_PATH ${ACMLROOT}/lib/)
89+
set(executables ${executables} ${executable})
11090

111-
include_directories(${ACMLROOT}/include)
91+
add_executable(${executable} ${source_file} )
92+
target_link_libraries(${executable} ${LINK_LIBS})
11293

113-
SET(BLAS_LIBRARIES "")
94+
set_property(TARGET ${executable} PROPERTY INSTALL_RPATH_USE_LINK_PATH TRUE)
95+
set_property(TARGET ${executable} PROPERTY INSTALL_RPATH ${INSTALL_RPATH} ${CMAKE_INSTALL_PREFIX}/lib)
11496

115-
SET(LAPACK_LIBRARIES
116-
${ACML_LIB_PATH}/libacml_mp_dll.lib
97+
endforeach(source_file)
98+
99+
100+
INSTALL(TARGETS ${executables}
101+
RUNTIME DESTINATION bin
102+
LIBRARY DESTINATION lib
103+
ARCHIVE DESTINATION lib
117104
)
118105

119-
add_definitions(-D_ACML)
106+
endfunction(add_all_executables)
107+
120108

121-
endif(USE_ACML)
109+
file(GLOB gurls_headers RELATIVE ${PROJECT_SOURCE_DIR} ${HDRDIR}*.h*)
110+
file(GLOB gurls_sources RELATIVE ${PROJECT_SOURCE_DIR} ${SRCDIR}*.cpp)
122111

123-
set(BUILD_SHARED_LIBS ON CACHE BOOL "Build a shared library (ON) or a static one (OFF)")
112+
113+
set(Boost_USE_MULTITHREADED ON)
114+
set(Boost_USE_STATIC_RUNTIME OFF)
115+
find_package( Boost COMPONENTS serialization date_time filesystem unit_test_framework system REQUIRED)
116+
option(Boost_USE_STATIC_LIBS "Link statically against boost libs" OFF)
117+
118+
if(Boost_FOUND)
119+
include_directories(${Boost_INCLUDE_DIRS})
120+
link_directories(${Boost_LIBRARY_DIRS})
121+
endif(Boost_FOUND)
122+
123+
include_directories( ${HDRDIR} )
124+
125+
126+
set(USE_BINARY_ARCHIVES OFF CACHE BOOL "If ON all the data structures in GURLS are saved/loaded using binary files.")
127+
128+
if(USE_BINARY_ARCHIVES)
129+
add_definitions(-DUSE_BINARY_ARCHIVES)
130+
endif(USE_BINARY_ARCHIVES)
131+
132+
set(BUILD_SHARED_LIBS OFF CACHE BOOL "Build a shared library (ON) or a static one (OFF)")
124133
if(BUILD_SHARED_LIBS)
125134
set( LIB_TYPE SHARED)
126135
else(BUILD_SHARED_LIBS)
127136
set(LIB_TYPE STATIC)
128137
endif(BUILD_SHARED_LIBS)
129138

130-
SET(CBLAS_INCLUDE_PATH "" CACHE PATH "")
131-
include_directories(${CBLAS_INCLUDE_PATH})
132139

133-
#ADD_DEFINITIONS( -Wall )
134-
IF(WIN32)
135-
ADD_DEFINITIONS(-D_SCL_SECURE_NO_WARNINGS)
140+
#add_definitions( -Wall )
136141

137-
add_definitions(-DGOTOBLAS)
138-
set(FORTRAN "")
139-
set(THREADINGLIB "")
140142

141-
SET(BLAS_LIBRARIES "")
142-
SET(LAPACK_LIBRARIES "" CACHE FILEPATH "")
143+
add_library(${GURLSLIBRARY} ${LIB_TYPE} ${gurls_headers} ${gurls_sources} )
144+
target_link_libraries(${GURLSLIBRARY} ${Boost_LIBRARIES} ${BLAS_LIBRARIES} ${LAPACK_LIBRARIES})
143145

144-
ELSEIF(WIN32)
145-
set(FORTRAN "gfortran")
146-
set(THREADINGLIB "pthread")
147-
ENDIF(WIN32)
146+
INSTALL(TARGETS ${GURLSLIBRARY}
147+
RUNTIME DESTINATION bin
148+
LIBRARY DESTINATION lib
149+
ARCHIVE DESTINATION lib
150+
)
148151

149-
add_library(${GURLSLIBRARY} ${LIB_TYPE} ${gurls_headers} ${gurls_sources} )
150-
target_link_libraries(${GURLSLIBRARY} ${FORTRAN} ${THREADINGLIB} ${Boost_LIBRARIES} ${BLAS_LIBRARIES} ${LAPACK_LIBRARIES} ${GPULIBRARY})
152+
if(MSVC)
151153

152-
IF(WIN32)
154+
add_definitions(-D_SCL_SECURE_NO_WARNINGS)
153155
set_target_properties(${GURLSLIBRARY} PROPERTIES COMPILE_FLAGS "/EHa")
156+
154157
if(BUILD_SHARED_LIBS)
155158
set_target_properties(${GURLSLIBRARY} PROPERTIES COMPILE_DEFINITIONS "_GURLS_EXPORTS")
156159
endif(BUILD_SHARED_LIBS)
157-
ENDIF(WIN32)
158160

161+
endif(MSVC)
159162

160-
add_executable(gurlsTutorial ${TUTORIALDIR}examplegurls.cpp )
161-
target_link_libraries(gurlsTutorial ${GURLSLIBRARY} ${Boost_LIBRARIES} ${LAPACK_LIBRARIES} ${BLAS_LIBRARIES} ${THREADINGLIB} ${GPULIBRARY})
162-
163-
add_executable(gurlsSimpleExample ${TUTORIALDIR}example.cpp)
164-
target_link_libraries(gurlsSimpleExample ${GURLSLIBRARY} ${THREADINGLIB} ${Boost_LIBRARIES} ${GPULIBRARY})
163+
set(GURLS_LINK_LIBRARIES
164+
${GURLSLIBRARY}
165+
${Boost_LIBRARIES}
166+
${LAPACK_LIBRARIES}
167+
${BLAS_LIBRARIES}
168+
)
165169

170+
set(BUILD_DEMO OFF CACHE BOOL "")
171+
if(BUILD_DEMO)
172+
add_all_executables(${PROJECT_SOURCE_DIR} ${DEMODIR} ${GURLS_LINK_LIBRARIES})
173+
endif(BUILD_DEMO)
166174

167175
set(BUILD_TEST OFF CACHE BOOL "")
168176
if(BUILD_TEST)
177+
set(GURLS_DATA_DIR "" CACHE PATH "Path to the Gurls++ data directory")
169178

170-
add_executable(GURLShoduallin ${TESTDIR}GURLShoduallin.cpp )
171-
target_link_libraries(GURLShoduallin ${GURLSLIBRARY} ${Boost_LIBRARIES} ${LAPACK_LIBRARIES} ${BLAS_LIBRARIES} ${THREADINGLIB} ${GPULIBRARY})
172-
173-
add_executable(GURLShoprimal ${TESTDIR}GURLShoprimal.cpp )
174-
target_link_libraries(GURLShoprimal ${GURLSLIBRARY} ${Boost_LIBRARIES} ${LAPACK_LIBRARIES} ${BLAS_LIBRARIES} ${THREADINGLIB} ${GPULIBRARY})
175-
176-
add_executable(GURLSloodualrbf ${TESTDIR}GURLSloodualrbf.cpp )
177-
target_link_libraries(GURLSloodualrbf ${GURLSLIBRARY} ${Boost_LIBRARIES} ${LAPACK_LIBRARIES} ${BLAS_LIBRARIES} ${THREADINGLIB} ${GPULIBRARY})
178-
179-
add_executable(GURLShodualrbf ${TESTDIR}GURLShodualrbf.cpp )
180-
target_link_libraries(GURLShodualrbf ${GURLSLIBRARY} ${Boost_LIBRARIES} ${LAPACK_LIBRARIES} ${BLAS_LIBRARIES} ${THREADINGLIB} ${GPULIBRARY})
181-
182-
add_executable(GURLSlooduallin ${TESTDIR}GURLSlooduallin.cpp )
183-
target_link_libraries(GURLSlooduallin ${GURLSLIBRARY} ${Boost_LIBRARIES} ${LAPACK_LIBRARIES} ${BLAS_LIBRARIES} ${THREADINGLIB} ${GPULIBRARY})
184-
185-
add_executable(GURLSlooprimal ${TESTDIR}GURLSlooprimal.cpp )
186-
target_link_libraries(GURLSlooprimal ${GURLSLIBRARY} ${Boost_LIBRARIES} ${LAPACK_LIBRARIES} ${BLAS_LIBRARIES} ${THREADINGLIB} ${GPULIBRARY})
179+
if(GURLS_DATA_DIR STREQUAL "")
180+
message(WARNING, "GURLS_DATA_DIR value is set to an empty string. Please be sure this is the right configuration for you")
181+
endif(GURLS_DATA_DIR STREQUAL "")
187182

188-
add_executable(GURLSpegasos ${TESTDIR}GURLSpegasos.cpp )
189-
target_link_libraries(GURLSpegasos ${GURLSLIBRARY} ${Boost_LIBRARIES} ${LAPACK_LIBRARIES} ${BLAS_LIBRARIES} ${THREADINGLIB} ${GPULIBRARY})
183+
add_definitions(-DGURLS_DATA_DIR="${GURLS_DATA_DIR}")
190184

185+
add_all_executables(${PROJECT_SOURCE_DIR} ${TESTDIR} ${GURLS_LINK_LIBRARIES})
191186
endif(BUILD_TEST)
192187

188+
# add a target to generate API documentation with Doxygen
189+
find_package(Doxygen)
190+
if(DOXYGEN_FOUND)
191+
configure_file(${CMAKE_CURRENT_SOURCE_DIR}/Doxyfile.in ${CMAKE_CURRENT_BINARY_DIR}/Doxyfile @ONLY)
192+
add_custom_target(doc
193+
${DOXYGEN_EXECUTABLE} ${CMAKE_CURRENT_BINARY_DIR}/Doxyfile
194+
WORKING_DIRECTORY ${CMAKE_CURRENT_BINARY_DIR}
195+
COMMENT "Generating API documentation with Doxygen" VERBATIM
196+
)
197+
endif(DOXYGEN_FOUND)

gurls++/doxygurls renamed to gurls++/Doxyfile.in

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -51,7 +51,7 @@ PROJECT_LOGO = doc/logo.png
5151
# If a relative path is entered, it will be relative to the location
5252
# where doxygen was started. If left blank the current directory will be used.
5353

54-
OUTPUT_DIRECTORY = doc
54+
OUTPUT_DIRECTORY = @CMAKE_CURRENT_SOURCE_DIR@/doc
5555

5656
# If the CREATE_SUBDIRS tag is set to YES, then doxygen will create
5757
# 4096 sub-directories (in 2 levels) under the output directory of each output
@@ -321,7 +321,7 @@ SYMBOL_CACHE_SIZE = 0
321321
# Private class members and static file members will be hidden unless
322322
# the EXTRACT_PRIVATE and EXTRACT_STATIC tags are set to YES
323323

324-
EXTRACT_ALL = YES
324+
EXTRACT_ALL = NO
325325

326326
# If the EXTRACT_PRIVATE tag is set to YES all private members of a class
327327
# will be included in the documentation.
@@ -612,7 +612,7 @@ WARN_LOGFILE =
612612
# directories like "/usr/src/myproject". Separate the files or directories
613613
# with spaces.
614614

615-
INPUT = .
615+
INPUT = @CMAKE_CURRENT_SOURCE_DIR@/include @CMAKE_CURRENT_SOURCE_DIR@/src
616616

617617
# This tag can be used to specify the character encoding of the source files
618618
# that doxygen parses. Internally doxygen uses the UTF-8 encoding, which is
@@ -667,7 +667,7 @@ FILE_PATTERNS = *.c \
667667
# should be searched for input files as well. Possible values are YES and NO.
668668
# If left blank NO is used.
669669

670-
RECURSIVE = YES
670+
RECURSIVE = NO
671671

672672
# The EXCLUDE tag can be used to specify files and/or directories that should
673673
# excluded from the INPUT source files. This way you can easily exclude a
@@ -701,7 +701,7 @@ EXCLUDE_SYMBOLS =
701701
# directories that contain example code fragments that are included (see
702702
# the \include command).
703703

704-
EXAMPLE_PATH =
704+
EXAMPLE_PATH = @CMAKE_CURRENT_SOURCE_DIR@/demo
705705

706706
# If the value of the EXAMPLE_PATH tag contains directories, you can use the
707707
# EXAMPLE_PATTERNS tag to specify one or more wildcard pattern (like *.cpp

0 commit comments

Comments
 (0)