Salut à tous !

Je dois mettre en place un système de construction d’un projet qui soit portable d’un système à un autre. Pour cela, j’utilise CMake. J’ai cependant un problème avec l’édition des liens sous MacOS X.

Voici l’arborescence du projet :

Code : Sélectionner tout - Visualiser dans une fenêtre à part
1
2
3
$ ls
CMakeLists.txt  CMakeModules  include  README.txt  src
Le répertoire « include » comporte les en-têtes :

Code : Sélectionner tout - Visualiser dans une fenêtre à part
1
2
3
4
$ ls include/
amd.h    elapse.h  macros.h     mpif.h  params.h  solverlib.h  types.h
const.h  eval.h    matrix_io.h  mpi.h   protos.h  space.h
Le répertoire « src » le reste des sources :

Code : Sélectionner tout - Visualiser dans une fenêtre à part
1
2
3
$ ls src/
convert.c  convertz.c  read_mat.c  solver.c  testlib.c  testlibz.c
Et le répertoire « CMakeModules » des modules que j’ai crée pour l’occasion :

Code : Sélectionner tout - Visualiser dans une fenêtre à part
1
2
3
$ ls CMakeModules/
FindCSPARSE.cmake  FindUFCONFIG.cmake
Le contenu du fichier « CMakeLists.txt » :

Code : Sélectionner tout - Visualiser dans une fenêtre à part
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
83
84
85
# CMake description file for compiling process of POC Solver.

cmake_minimum_required(VERSION 2.6)

# Ensuring that packages are found
set(CMAKE_MODULE_PATH ${CMAKE_MODULE_PATH} CMakeModules)

# Project configuration
project(POC-Solvers)
set(LIBRARY_OUTPUT_PATH lib/${CMAKE_BUILD_TYPE})
set(EXECUTABLE_OUTPUT_PATH bin/${CMAKE_BUILD_TYPE})

# Including libraies
find_package(UFCONFIG)
find_package(CSPARSE)
link_directories(${CSPARSE_LIBRARY}
		 ${CMAKE_SOURCE_DIR}/lib/${CMAKE_BUILD_TYPE})

# Public headers inclusion path
include_directories(${CSPARSE_INCLUDE_DIR}
		    ${UFCONFIG_INCLUDE_DIR}
		    include)

# Library configuration
file(
	GLOB_RECURSE
	source_files
	include/*
)
add_library(
	poc-solvers
	SHARED
	${source_files}
	src/convert.c
	src/convertz.c
	src/read_mat.c
	src/solver.c
)

# Link edition configuration
target_link_libraries(
	poc-solvers
	${CSPARSE_LIBRARIES}
)

# Library installer
install (TARGETS poc-solvers DESTINATION bin)
install (FILES ${sources_files} DESTINATION include/poc)

# Should we compile the first set of tests?
option (COMPILE_TESTLIB
        "Compile real numbers set of tests for POC Solver"
	ON)

if (COMPILE_TESTLIB)
   add_executable (
   	testlib
	${sources_files}
	src/testlib.c
   )
   target_link_libraries(
	testlib
	poc-solvers
	${CSPARSE_LIBRARIES}
   )
endif (COMPILE_TESTLIB)

# Should we compile the second set of tests?
option (COMPILE_TESTLIBZ
        "Compile complex numbers set of tests for POC Solver"
	ON)

if (COMPILE_TESTLIBZ)
   add_executable (
   	testlibz
	${sources_files}
	src/testlibz.c
   )
   target_link_libraries(
	testlibz
	poc-solvers
	${CSPARSE_LIBRARIES}
   )
endif (COMPILE_TESTLIBZ)
Voici le résultat que j’obtiens sur différentes distributions GNU/Linux – Fedora, Debian et Ubuntu, pas encore testé sous Gentoo, mais je pense que le résultat sera le même :

Code : Sélectionner tout - Visualiser dans une fenêtre à part
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
$ cmake -G "Unix Makefiles"
-- The C compiler identification is GNU
-- The CXX compiler identification is GNU
-- Check for working C compiler: /usr/bin/gcc
-- Check for working C compiler: /usr/bin/gcc -- works
-- Detecting C compiler ABI info
-- Detecting C compiler ABI info - done
-- Check for working CXX compiler: /usr/bin/c++
-- Check for working CXX compiler: /usr/bin/c++ -- works
-- Detecting CXX compiler ABI info
-- Detecting CXX compiler ABI info - done
-- Found UFCONFIG: /usr/include/suitesparse
-- Found CSPARSE: /usr/lib/libcxsparse.so
-- Configuring done
-- Generating done
-- Build files have been written to: /home/yoann/T-UGOm/new/poc-solvers
Ensuite, je modifie le fichier CMakeCache.txt afin qu’il ait cet aspect :

Code : Sélectionner tout - Visualiser dans une fenêtre à part
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
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
# This is the CMakeCache file.
# For build in directory: /home/yoann/T-UGOm/new/poc-solvers
# It was generated by CMake: /usr/bin/cmake
# You can edit this file to change values found and used by cmake.
# If you do not want to change any of the values, simply exit the editor.
# If you do want to change a value, simply edit, save, and exit the editor.
# The syntax for the file is as follows:
# KEY:TYPE=VALUE
# KEY is the name of a variable in the cache.
# TYPE is a hint to GUI's for the type of VALUE, DO NOT EDIT TYPE!.
# VALUE is the current value for the KEY.

########################
# EXTERNAL cache entries
########################

//Path to a program.
CMAKE_AR:FILEPATH=/usr/bin/ar

//Choose the type of build, options are: None(CMAKE_CXX_FLAGS or
// CMAKE_C_FLAGS used) Debug Release RelWithDebInfo MinSizeRel.
CMAKE_BUILD_TYPE:STRING=Debug

//Enable/Disable color output during build.
CMAKE_COLOR_MAKEFILE:BOOL=ON

//CXX compiler.
CMAKE_CXX_COMPILER:FILEPATH=/usr/bin/c++

//Flags used by the compiler during all build types.
CMAKE_CXX_FLAGS:STRING=

//Flags used by the compiler during debug builds.
CMAKE_CXX_FLAGS_DEBUG:STRING=-g -ansi -pedantic -Wall

//Flags used by the compiler during release minsize builds.
CMAKE_CXX_FLAGS_MINSIZEREL:STRING=-Os -DNDEBUG

//Flags used by the compiler during release builds (/MD /Ob1 /Oi
// /Ot /Oy /Gs will produce slightly less optimized but smaller
// files).
CMAKE_CXX_FLAGS_RELEASE:STRING=-march=native -O2 -DNDEBUG -pipe

//Flags used by the compiler during Release with Debug Info builds.
CMAKE_CXX_FLAGS_RELWITHDEBINFO:STRING=-march=native -O2 -g -pipe

//C compiler.
CMAKE_C_COMPILER:FILEPATH=/usr/bin/gcc

//Flags used by the compiler during all build types.
CMAKE_C_FLAGS:STRING=

//Flags used by the compiler during debug builds.
CMAKE_C_FLAGS_DEBUG:STRING=-g -std=c99 -pedantic -W -Wall

//Flags used by the compiler during release minsize builds.
CMAKE_C_FLAGS_MINSIZEREL:STRING=-Os -DNDEBUG

//Flags used by the compiler during release builds (/MD /Ob1 /Oi
// /Ot /Oy /Gs will produce slightly less optimized but smaller
// files).
CMAKE_C_FLAGS_RELEASE:STRING=-march=native -O2 -DNDEBUG -pipe

//Flags used by the compiler during Release with Debug Info builds.
CMAKE_C_FLAGS_RELWITHDEBINFO:STRING=-march=native -O2 -g -pipe

//Flags used by the linker.
CMAKE_EXE_LINKER_FLAGS:STRING=

//Flags used by the linker during debug builds.
CMAKE_EXE_LINKER_FLAGS_DEBUG:STRING=

//Flags used by the linker during release minsize builds.
CMAKE_EXE_LINKER_FLAGS_MINSIZEREL:STRING=

//Flags used by the linker during release builds.
CMAKE_EXE_LINKER_FLAGS_RELEASE:STRING=

//Flags used by the linker during Release with Debug Info builds.
CMAKE_EXE_LINKER_FLAGS_RELWITHDEBINFO:STRING=

//Install path prefix, prepended onto install directories.
CMAKE_INSTALL_PREFIX:PATH=/usr/local

//Path to a program.
CMAKE_LINKER:FILEPATH=/usr/bin/ld

//Path to a program.
CMAKE_MAKE_PROGRAM:FILEPATH=/usr/bin/make

//Flags used by the linker during the creation of modules.
CMAKE_MODULE_LINKER_FLAGS:STRING=

//Flags used by the linker during debug builds.
CMAKE_MODULE_LINKER_FLAGS_DEBUG:STRING=

//Flags used by the linker during release minsize builds.
CMAKE_MODULE_LINKER_FLAGS_MINSIZEREL:STRING=

//Flags used by the linker during release builds.
CMAKE_MODULE_LINKER_FLAGS_RELEASE:STRING=

//Flags used by the linker during Release with Debug Info builds.
CMAKE_MODULE_LINKER_FLAGS_RELWITHDEBINFO:STRING=

//Path to a program.
CMAKE_NM:FILEPATH=/usr/bin/nm

//Path to a program.
CMAKE_OBJCOPY:FILEPATH=/usr/bin/objcopy

//Path to a program.
CMAKE_OBJDUMP:FILEPATH=/usr/bin/objdump

//Value Computed by CMake
CMAKE_PROJECT_NAME:STATIC=POC-Solvers

//Path to a program.
CMAKE_RANLIB:FILEPATH=/usr/bin/ranlib

//Flags used by the linker during the creation of dll's.
CMAKE_SHARED_LINKER_FLAGS:STRING=

//Flags used by the linker during debug builds.
CMAKE_SHARED_LINKER_FLAGS_DEBUG:STRING=

//Flags used by the linker during release minsize builds.
CMAKE_SHARED_LINKER_FLAGS_MINSIZEREL:STRING=

//Flags used by the linker during release builds.
CMAKE_SHARED_LINKER_FLAGS_RELEASE:STRING=

//Flags used by the linker during Release with Debug Info builds.
CMAKE_SHARED_LINKER_FLAGS_RELWITHDEBINFO:STRING=

//If set, runtime paths are not added when using shared libraries.
CMAKE_SKIP_RPATH:BOOL=NO

//Path to a program.
CMAKE_STRIP:FILEPATH=/usr/bin/strip

//If true, cmake will use relative paths in makefiles and projects.
CMAKE_USE_RELATIVE_PATHS:BOOL=OFF

//If this value is on, makefiles will be generated without the
// .SILENT directive, and all commands will be echoed to the console
// during the make.  This is useful for debugging only. With Visual
// Studio IDE projects all commands are done without /nologo.
CMAKE_VERBOSE_MAKEFILE:BOOL=FALSE

//Compile real numbers set of tests for POC Solver
COMPILE_TESTLIB:BOOL=ON

//Compile complex numbers set of tests for POC Solver
COMPILE_TESTLIBZ:BOOL=ON

//Path to a file.
CSPARSE_CSPARSE_INCLUDE_DIR:PATH=/usr/include/suitesparse

//Path to a library.
CSPARSE_LIBRARY:FILEPATH=/usr/lib/libcxsparse.so

//Value Computed by CMake
POC-Solvers_BINARY_DIR:STATIC=/home/farfadet/T-UGOm/new/poc-solvers

//Value Computed by CMake
POC-Solvers_SOURCE_DIR:STATIC=/home/farfadet/T-UGOm/new/poc-solvers

//Path to a file.
UFCONFIG_UFCONFIG_INCLUDE_DIR:PATH=/usr/include/suitesparse

//Dependencies for the target
poc-solvers_LIB_DEPENDS:STATIC=general;/usr/lib/libcxsparse.so;


########################
# INTERNAL cache entries
########################

//ADVANCED property for variable: CMAKE_AR
CMAKE_AR-ADVANCED:INTERNAL=1
//ADVANCED property for variable: CMAKE_BUILD_TOOL
CMAKE_BUILD_TOOL-ADVANCED:INTERNAL=1
//What is the target build tool cmake is generating for.
CMAKE_BUILD_TOOL:INTERNAL=/usr/bin/make
//This is the directory where this CMakeCache.txt was created
CMAKE_CACHEFILE_DIR:INTERNAL=/home/farfadet/T-UGOm/new/poc-solvers
//Major version of cmake used to create the current loaded cache
CMAKE_CACHE_MAJOR_VERSION:INTERNAL=2
//Minor version of cmake used to create the current loaded cache
CMAKE_CACHE_MINOR_VERSION:INTERNAL=8
//Patch version of cmake used to create the current loaded cache
CMAKE_CACHE_PATCH_VERSION:INTERNAL=2
//ADVANCED property for variable: CMAKE_COLOR_MAKEFILE
CMAKE_COLOR_MAKEFILE-ADVANCED:INTERNAL=1
//Path to CMake executable.
CMAKE_COMMAND:INTERNAL=/usr/bin/cmake
//Path to cpack program executable.
CMAKE_CPACK_COMMAND:INTERNAL=/usr/bin/cpack
//Path to ctest program executable.
CMAKE_CTEST_COMMAND:INTERNAL=/usr/bin/ctest
//ADVANCED property for variable: CMAKE_CXX_COMPILER
CMAKE_CXX_COMPILER-ADVANCED:INTERNAL=1
CMAKE_CXX_COMPILER_WORKS:INTERNAL=1
//ADVANCED property for variable: CMAKE_CXX_FLAGS
CMAKE_CXX_FLAGS-ADVANCED:INTERNAL=1
//ADVANCED property for variable: CMAKE_CXX_FLAGS_DEBUG
CMAKE_CXX_FLAGS_DEBUG-ADVANCED:INTERNAL=1
//ADVANCED property for variable: CMAKE_CXX_FLAGS_MINSIZEREL
CMAKE_CXX_FLAGS_MINSIZEREL-ADVANCED:INTERNAL=1
//ADVANCED property for variable: CMAKE_CXX_FLAGS_RELEASE
CMAKE_CXX_FLAGS_RELEASE-ADVANCED:INTERNAL=1
//ADVANCED property for variable: CMAKE_CXX_FLAGS_RELWITHDEBINFO
CMAKE_CXX_FLAGS_RELWITHDEBINFO-ADVANCED:INTERNAL=1
//ADVANCED property for variable: CMAKE_C_COMPILER
CMAKE_C_COMPILER-ADVANCED:INTERNAL=1
CMAKE_C_COMPILER_WORKS:INTERNAL=1
//ADVANCED property for variable: CMAKE_C_FLAGS
CMAKE_C_FLAGS-ADVANCED:INTERNAL=1
//ADVANCED property for variable: CMAKE_C_FLAGS_DEBUG
CMAKE_C_FLAGS_DEBUG-ADVANCED:INTERNAL=1
//ADVANCED property for variable: CMAKE_C_FLAGS_MINSIZEREL
CMAKE_C_FLAGS_MINSIZEREL-ADVANCED:INTERNAL=1
//ADVANCED property for variable: CMAKE_C_FLAGS_RELEASE
CMAKE_C_FLAGS_RELEASE-ADVANCED:INTERNAL=1
//ADVANCED property for variable: CMAKE_C_FLAGS_RELWITHDEBINFO
CMAKE_C_FLAGS_RELWITHDEBINFO-ADVANCED:INTERNAL=1
//Result of TRY_COMPILE
CMAKE_DETERMINE_CXX_ABI_COMPILED:INTERNAL=TRUE
//Result of TRY_COMPILE
CMAKE_DETERMINE_C_ABI_COMPILED:INTERNAL=TRUE
//Path to cache edit program executable.
CMAKE_EDIT_COMMAND:INTERNAL=/usr/bin/cmake-gui
//Executable file format
CMAKE_EXECUTABLE_FORMAT:INTERNAL=ELF
//ADVANCED property for variable: CMAKE_EXE_LINKER_FLAGS
CMAKE_EXE_LINKER_FLAGS-ADVANCED:INTERNAL=1
//ADVANCED property for variable: CMAKE_EXE_LINKER_FLAGS_DEBUG
CMAKE_EXE_LINKER_FLAGS_DEBUG-ADVANCED:INTERNAL=1
//ADVANCED property for variable: CMAKE_EXE_LINKER_FLAGS_MINSIZEREL
CMAKE_EXE_LINKER_FLAGS_MINSIZEREL-ADVANCED:INTERNAL=1
//ADVANCED property for variable: CMAKE_EXE_LINKER_FLAGS_RELEASE
CMAKE_EXE_LINKER_FLAGS_RELEASE-ADVANCED:INTERNAL=1
//ADVANCED property for variable: CMAKE_EXE_LINKER_FLAGS_RELWITHDEBINFO
CMAKE_EXE_LINKER_FLAGS_RELWITHDEBINFO-ADVANCED:INTERNAL=1
//Name of generator.
CMAKE_GENERATOR:INTERNAL=Unix Makefiles
//Start directory with the top level CMakeLists.txt file for this
// project
CMAKE_HOME_DIRECTORY:INTERNAL=/home/farfadet/T-UGOm/new/poc-solvers
//Install .so files without execute permission.
CMAKE_INSTALL_SO_NO_EXE:INTERNAL=1
//ADVANCED property for variable: CMAKE_LINKER
CMAKE_LINKER-ADVANCED:INTERNAL=1
//ADVANCED property for variable: CMAKE_MAKE_PROGRAM
CMAKE_MAKE_PROGRAM-ADVANCED:INTERNAL=1
//ADVANCED property for variable: CMAKE_MODULE_LINKER_FLAGS
CMAKE_MODULE_LINKER_FLAGS-ADVANCED:INTERNAL=1
//ADVANCED property for variable: CMAKE_MODULE_LINKER_FLAGS_DEBUG
CMAKE_MODULE_LINKER_FLAGS_DEBUG-ADVANCED:INTERNAL=1
//ADVANCED property for variable: CMAKE_MODULE_LINKER_FLAGS_MINSIZEREL
CMAKE_MODULE_LINKER_FLAGS_MINSIZEREL-ADVANCED:INTERNAL=1
//ADVANCED property for variable: CMAKE_MODULE_LINKER_FLAGS_RELEASE
CMAKE_MODULE_LINKER_FLAGS_RELEASE-ADVANCED:INTERNAL=1
//ADVANCED property for variable: CMAKE_MODULE_LINKER_FLAGS_RELWITHDEBINFO
CMAKE_MODULE_LINKER_FLAGS_RELWITHDEBINFO-ADVANCED:INTERNAL=1
//ADVANCED property for variable: CMAKE_NM
CMAKE_NM-ADVANCED:INTERNAL=1
//number of local generators
CMAKE_NUMBER_OF_LOCAL_GENERATORS:INTERNAL=1
//ADVANCED property for variable: CMAKE_OBJCOPY
CMAKE_OBJCOPY-ADVANCED:INTERNAL=1
//ADVANCED property for variable: CMAKE_OBJDUMP
CMAKE_OBJDUMP-ADVANCED:INTERNAL=1
//ADVANCED property for variable: CMAKE_RANLIB
CMAKE_RANLIB-ADVANCED:INTERNAL=1
//Path to CMake installation.
CMAKE_ROOT:INTERNAL=/usr/share/cmake-2.8
//ADVANCED property for variable: CMAKE_SHARED_LINKER_FLAGS
CMAKE_SHARED_LINKER_FLAGS-ADVANCED:INTERNAL=1
//ADVANCED property for variable: CMAKE_SHARED_LINKER_FLAGS_DEBUG
CMAKE_SHARED_LINKER_FLAGS_DEBUG-ADVANCED:INTERNAL=1
//ADVANCED property for variable: CMAKE_SHARED_LINKER_FLAGS_MINSIZEREL
CMAKE_SHARED_LINKER_FLAGS_MINSIZEREL-ADVANCED:INTERNAL=1
//ADVANCED property for variable: CMAKE_SHARED_LINKER_FLAGS_RELEASE
CMAKE_SHARED_LINKER_FLAGS_RELEASE-ADVANCED:INTERNAL=1
//ADVANCED property for variable: CMAKE_SHARED_LINKER_FLAGS_RELWITHDEBINFO
CMAKE_SHARED_LINKER_FLAGS_RELWITHDEBINFO-ADVANCED:INTERNAL=1
//ADVANCED property for variable: CMAKE_SKIP_RPATH
CMAKE_SKIP_RPATH-ADVANCED:INTERNAL=1
//ADVANCED property for variable: CMAKE_STRIP
CMAKE_STRIP-ADVANCED:INTERNAL=1
//uname command
CMAKE_UNAME:INTERNAL=/bin/uname
//ADVANCED property for variable: CMAKE_USE_RELATIVE_PATHS
CMAKE_USE_RELATIVE_PATHS-ADVANCED:INTERNAL=1
//ADVANCED property for variable: CMAKE_VERBOSE_MAKEFILE
CMAKE_VERBOSE_MAKEFILE-ADVANCED:INTERNAL=1
//ADVANCED property for variable: CSPARSE_CSPARSE_INCLUDE_DIR
CSPARSE_CSPARSE_INCLUDE_DIR-ADVANCED:INTERNAL=1
//ADVANCED property for variable: CSPARSE_LIBRARY
CSPARSE_LIBRARY-ADVANCED:INTERNAL=1
//Details about finding CSPARSE
FIND_PACKAGE_MESSAGE_DETAILS_CSPARSE:INTERNAL=[/usr/lib/libcxsparse.so][/usr/include/suitesparse]
//Details about finding UFCONFIG
FIND_PACKAGE_MESSAGE_DETAILS_UFCONFIG:INTERNAL=[/usr/include/suitesparse]
//ADVANCED property for variable: UFCONFIG_UFCONFIG_INCLUDE_DIR
UFCONFIG_UFCONFIG_INCLUDE_DIR-ADVANCED:INTERNAL=1
Pour prendre en compte ces modifications, je relance CMake :

Code : Sélectionner tout - Visualiser dans une fenêtre à part
1
2
3
4
5
$ cmake -G "Unix Makefiles"
-- Configuring done
-- Generating done
-- Build files have been written to: /home/yoann/T-UGOm/new/poc-solvers
Voici ce que j’obtiens en lançant effectivement la compilation :

Code : Sélectionner tout - Visualiser dans une fenêtre à part
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
$ make
Scanning dependencies of target poc-solvers
[ 16%] Building C object CMakeFiles/poc-solvers.dir/src/convert.c.o
[ 33%] Building C object CMakeFiles/poc-solvers.dir/src/convertz.c.o
[ 50%] Building C object CMakeFiles/poc-solvers.dir/src/read_mat.c.o
[ 66%] Building C object CMakeFiles/poc-solvers.dir/src/solver.c.o
Linking C shared library lib/Debug/libpoc-solvers.so
[ 66%] Built target poc-solvers
Scanning dependencies of target testlib
[ 83%] Building C object CMakeFiles/testlib.dir/src/testlib.c.o
Linking C executable bin/Debug/testlib
[ 83%] Built target testlib
Scanning dependencies of target testlibz
[100%] Building C object CMakeFiles/testlibz.dir/src/testlibz.c.o
Linking C executable bin/Debug/testlibz
[100%] Built target testlibz
En revanche, sous MacOS X, le résultat est moins bon. Je vous donne les résultats avec des fichiers Makefiles car c’est plus simple pour le copier-coller, mais le résultat est le même en passant par Xcode. La première exécution de CMake :

Code : Sélectionner tout - Visualiser dans une fenêtre à part
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
$ cmake -G "Unix Makefiles"
-- The C compiler identification is GNU
-- The CXX compiler identification is GNU
-- Checking whether C compiler has -isysroot
-- Checking whether C compiler has -isysroot - yes
-- Checking whether C compiler supports OSX deployment target flag
-- Checking whether C compiler supports OSX deployment target flag - yes
-- Check for working C compiler: /usr/bin/gcc
-- Check for working C compiler: /usr/bin/gcc -- works
-- Detecting C compiler ABI info
-- Detecting C compiler ABI info - done
-- Checking whether CXX compiler has -isysroot
-- Checking whether CXX compiler has -isysroot - yes
-- Checking whether CXX compiler supports OSX deployment target flag
-- Checking whether CXX compiler supports OSX deployment target flag - yes
-- Check for working CXX compiler: /usr/bin/c++
-- Check for working CXX compiler: /usr/bin/c++ -- works
-- Detecting CXX compiler ABI info
-- Detecting CXX compiler ABI info - done
-- Found UFCONFIG: /opt/local/include/ufsparse 
-- Found CSPARSE: /opt/local/lib/libcxsparse.a 
-- Configuring done
-- Generating done
-- Build files have been written to: /Users/ylebars/T-UGOm/new/unix/poc-solvers
Après avoir modifié « CMakeCache.txt » comme précédemment :

Code : Sélectionner tout - Visualiser dans une fenêtre à part
1
2
3
4
5
$ cmake -G "Unix Makefiles"
-- Configuring done
-- Generating done
-- Build files have been written to: /Users/ylebars/T-UGOm/new/unix/poc-solvers
Le probème arrive dans l’édition des liens :

Code : Sélectionner tout - Visualiser dans une fenêtre à part
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
$ make
Scanning dependencies of target poc-solvers
[ 16%] Building C object CMakeFiles/poc-solvers.dir/src/convert.c.o
[ 33%] Building C object CMakeFiles/poc-solvers.dir/src/convertz.c.o
[ 50%] Building C object CMakeFiles/poc-solvers.dir/src/read_mat.c.o
[ 66%] Building C object CMakeFiles/poc-solvers.dir/src/solver.c.o
Linking C shared library lib/Debug/libpoc-solvers.dylib
ld: warning: path '/opt/local/lib/libcxsparse.a' following -L not a directory
[ 66%] Built target poc-solvers
Scanning dependencies of target testlib
[ 83%] Building C object CMakeFiles/testlib.dir/src/testlib.c.o
Linking C executable bin/Debug/testlib
ld: warning: path '/opt/local/lib/libcxsparse.a' following -L not a directory
[ 83%] Built target testlib
Scanning dependencies of target testlibz
[100%] Building C object CMakeFiles/testlibz.dir/src/testlibz.c.o
Linking C executable bin/Debug/testlibz
ld: warning: path '/opt/local/lib/libcxsparse.a' following -L not a directory
[100%] Built target testlibz
Je pense que le problème vient des modules que j’ai réalisés (en me basant sur ce que j’ai trouvé sur le net), mais j’ai fait plusieurs essais qui se sont avérés vain. C’est sans doute une erreur bête, mais je n’arrive pas à la corriger.

Le contenu du fichier « FindUFCONFIG.cmake » :

Code : Sélectionner tout - Visualiser dans une fenêtre à part
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
# - Find the UFconfig include
#
# This module defines
#  UFCONFIG_INCLUDE_DIR, where to find UFconfig.h, etc.
#  UFCONFIG_FOUND, If false, do not try to use UFconfig.

#=============================================================================
# Copyright 2010, Martin Koehler
# http://www-user.tu-chemnitz.de/~komart/
#
# Distributed under the OSI-approved BSD License (the "License");
# see accompanying file Copyright.txt for details.
#
# This software is distributed WITHOUT ANY WARRANTY; without even the
# implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.
# See the License for more information.
#=============================================================================
# Modifications: Yoann Le Bars
# Date: Jan. 28, 2011

find_path(UFCONFIG_UFCONFIG_INCLUDE_DIR UFconfig.h
	/usr/include
	/usr/local/include
	/opt/local/include/ufsparse	# MacOS X - MacPorts
	/usr/local/include/suitesparse 	# FreeBSD
	/usr/include/suitesparse	# Debian
	${SUITESPARSE}/UFconfig  	#Local Setup
  )

if (UFCONFIG_UFCONFIG_INCLUDE_DIR )
      SET(UFCONFIG_INCLUDE_DIR ${UFCONFIG_UFCONFIG_INCLUDE_DIR} )
endif (UFCONFIG_UFCONFIG_INCLUDE_DIR)


# handle the QUIETLY and REQUIRED arguments and set UFconfig_FOUND to TRUE if
# all listed variables are TRUE
include(FindPackageHandleStandardArgs)
find_package_handle_standard_args(UFCONFIG  DEFAULT_MSG  UFCONFIG_UFCONFIG_INCLUDE_DIR)

mark_as_advanced(UFCONFIG_UFCONFIG_INCLUDE_DIR )
Et le fichier « FindCSPARSE.cmake » :

Code : Sélectionner tout - Visualiser dans une fenêtre à part
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
# - Find the CXSPARSE includes and library
#
# This module defines
#  CSPARSE_INCLUDE_DIR, where to find umfpack.h, etc.
#  CSPARSE_LIBRARIES, the libraries to link against to use CSPARSE.
#  CSPARSE_FOUND, If false, do not try to use CSPARSE.
# also defined, but not for general use are
#  CSPARSE_LIBRARY, where to find the CSPARSE library.
#
#
# A system wide installed CSPARSE is mapped to CXSPARSE on nearly all systems
# (tested on FreeBSD, Debian GNU/Linux, Gentoo)

#=============================================================================
# Copyright 2010, Martin Koehler
# http://www-user.tu-chemnitz.de/~komart/
#
# Distributed under the OSI-approved BSD License (the "License");
# see accompanying file Copyright.txt for details.
#
# This software is distributed WITHOUT ANY WARRANTY; without even the
# implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.
# See the License for more information.
#=============================================================================
# Modification by: Yoann Le Bars
# Date: Jan. 28, 2011

find_path(CSPARSE_CSPARSE_INCLUDE_DIR cs.h
	/usr/include
	/usr/local/include
	/opt/local/include/ufsparse	# MacOS X - MacPorts
	/usr/local/include/suitesparse 	# FreeBSD
	/usr/include/suitesparse	# Debian
	${SUITESPARSE}/CSparse/Include  # Local Setup
  )

# set(CSPARSE_NAMES ${CSPARSE_NAMES} cxsparse libcxsparse)
set(CSPARSE_NAMES cxsparse libcxsparse)
find_library(CSPARSE_LIBRARY NAMES ${CSPARSE_NAMES}
	/opt/local/lib			# MacOS X - MacPorts
	/usr/lib
	/usr/local/lib
	/usr/lib64
	/usr/local/lib64
	${SUITESPARSE}/CXSparse/Lib 
	)

if (CSPARSE_LIBRARY AND CSPARSE_CSPARSE_INCLUDE_DIR)
      SET(CSPARSE_INCLUDE_DIR ${CSPARSE_CSPARSE_INCLUDE_DIR} )
      SET(CSPARSE_LIBRARIES ${CSPARSE_LIBRARY} )
endif (CSPARSE_LIBRARY AND CSPARSE_CSPARSE_INCLUDE_DIR)

# handle the QUIETLY and REQUIRED arguments and set AMD_FOUND to TRUE if
# all listed variables are TRUE
include(FindPackageHandleStandardArgs)
find_package_handle_standard_args(CSPARSE DEFAULT_MSG CSPARSE_LIBRARY CSPARSE_CSPARSE_INCLUDE_DIR)

mark_as_advanced(CSPARSE_CSPARSE_INCLUDE_DIR CSPARSE_LIBRARY)
Le résultat de quelques commandes, qui je pense peuvent aider :

Code : Sélectionner tout - Visualiser dans une fenêtre à part
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
$ ls /opt/local/include/ufsparse/
SuiteSparseQR_C.h           umfpack_defaults.h
SuiteSparseQR_definitions.h umfpack_free_numeric.h
UFconfig.h                  umfpack_free_symbolic.h
amd.h                       umfpack_get_determinant.h
amd_internal.h              umfpack_get_lunz.h
btf.h                       umfpack_get_numeric.h
btf_internal.h              umfpack_get_symbolic.h
camd.h                      umfpack_global.h
camd_internal.h             umfpack_load_numeric.h
ccolamd.h                   umfpack_load_symbolic.h
cholmod.h                   umfpack_numeric.h
cholmod_blas.h              umfpack_qsymbolic.h
cholmod_check.h             umfpack_report_control.h
cholmod_cholesky.h          umfpack_report_info.h
cholmod_complexity.h        umfpack_report_matrix.h
cholmod_config.h            umfpack_report_numeric.h
cholmod_core.h              umfpack_report_perm.h
cholmod_internal.h          umfpack_report_status.h
cholmod_io64.h              umfpack_report_symbolic.h
cholmod_matrixops.h         umfpack_report_triplet.h
cholmod_modify.h            umfpack_report_vector.h
cholmod_partition.h         umfpack_save_numeric.h
cholmod_supernodal.h        umfpack_save_symbolic.h
cholmod_template.h          umfpack_scale.h
colamd.h                    umfpack_solve.h
cs.h                        umfpack_symbolic.h
klu.h                       umfpack_tictoc.h
klu_internal.h              umfpack_timer.h
klu_version.h               umfpack_transpose.h
ldl.h                       umfpack_triplet_to_col.h
umfpack.h                   umfpack_wsolve.h
umfpack_col_to_triplet.h

$ ls /opt/local/lib/ | grep sparse
libcsparse.a
libcxsparse.a
Donc, si quelqu’un a une idée pour me sortir de là, je suis preneur.

À bientôt.

Le Farfadet Spatial