Bonjour à tous,

je suis un peu nouveau sur l'utilisation de CMake, donc ne m'en veuillez pas si j'ai l'air de dire des bêtises.

Je vous présente mon problème, je travaille sur un projet qui doit compiler sur Windows et sur Linux. Pour la partie Linux, il a été décidé d'utiliser CMake pour compiler le projet. Voici l'arborescence du projet:

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
Manager/
     |___ Bin
     |___ Includes
              |___ lib1
                     |___ lib1.h
              |___ lib2
                     |___ lib2.h
              |___ Manager
                     |___ manager.h
     |___ Src
              |___ lib1
                     |___ lib1.cpp
                     |___ CMakeList.txt (2)
              |___ lib2
                     |___ lib2.cpp
                     |___ CMakeList.txt (3)
              |___ Manager
                     |___ Manager.cpp
                     |___ CMakeList.txt (4)
     |___ Project
     |___ CMakeList.txt (1)
Voici les fichiers CMakeList que j'utilise:
(1)
Code : Sélectionner tout - Visualiser dans une fenêtre à part
1
2
3
4
5
6
7
8
9
10
11
# Set the cmake version
cmake_minimum_required(VERSION 2.6)
 
set(BUILD_SHARED_LIBS ON)
set(BUILD_PATH "Bin/${CMAKE_BUILD_TYPE}/")
MESSAGE( "General build path ${BUILD_PATH}" )
 
# Set the list of directory which contain the other CMakeList
add_subdirectory(Src/lib1)
add_subdirectory(Src/lib2)
add_subdirectory(Src/Manager)

(2)
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
 
# Set the cmake version
cmake_minimum_required(VERSION 2.6)
 
# Set the project name
project(lib1)
 
# Configure project
set(BUILD_SHARED_LIBS ON)
set(BUILD_PATH "${CMAKE_BUILD_TYPE}/")
 
#Display Build path
set(LIBRARY_OUTPUT_PATH ../../Bin/${BUILD_PATH})
 
#Include .h files directory
include_directories(../../Includes/lib1)
 
#Define librarie
add_library(
	lib1
	SHARED
       ../../Includes/lib1/lib1.h
      lib1.cpp
)
 
set_target_properties(lib1 PROPERTIES PREFIX "")
(3)
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
 
# Set the cmake version
cmake_minimum_required(VERSION 2.6)
 
# Set the project name
project(lib2)
 
# Configure project
set(BUILD_SHARED_LIBS ON)
set(BUILD_PATH "${CMAKE_BUILD_TYPE}/")
 
#Display Build path
set(LIBRARY_OUTPUT_PATH ../../Bin/${BUILD_PATH})
 
#Include .h files directory
include_directories(../../Includes/lib1 ../../Includes/lib2)
link_directories(../../Bin/${BUILD_PATH})
 
#Define librarie
add_library(
	lib2
	SHARED
       ../../Includes/lib2/lib2.h
      lib2.cpp
)
 
target_link_libraries(
	lib2
	lib1
)
 
set_target_properties(lib2 PROPERTIES PREFIX "")
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
 
# Set the cmake version
cmake_minimum_required(VERSION 2.6)
 
# Set the project name
project(Manager)
 
# Configure project
set(BUILD_SHARED_LIBS ON)
set(BUILD_PATH "${CMAKE_BUILD_TYPE}/")
set(EXECUTABLE_OUTPUT_PATH ../../Bin/${BUILD_PATH})
 
#Include .h files directory
include_directories(../../Includes/lib1
../../Includes/lib2
../../Includes/Manager)
 
#Define link libraries folder
link_directories(../../Bin/${BUILD_PATH})
 
add_executable(
	Manager
	../../Includes/Manager/Manager.h
	Manager.cpp
)
 
target_link_libraries(
	Manager
	lib1
	lib2
	pthread
)
 
set_target_properties(Manager PROPERTIES PREFIX "")
Sachant que la librairie lib1 utilise lib2 et que le Manager utilise lib1 et lib2 (plus des threads).

Ma première question est la suivante: est ce que mes CMakeList sont juste?
Ensuite, pourquoi, lorsque j'essaie de fournir les fichiers lib1.so, lib2.so et Manager, ceux-ci ne fonctionnent pas sur un autre poste?

Le problème semble venir du fait que les chemins de link sont en dur dans l’exécutable et je ne vois pas du tout comment corriger cela

Merci beaucoup de l'aide que vous pourrez m'apporter

Bonne journée