Skip to content

Commit 1d34aec

Browse files
committed
Fix problem with examples find_package
1 parent 9495ae4 commit 1d34aec

4 files changed

Lines changed: 32 additions & 23 deletions

File tree

examples/CMakeLists.txt

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -21,7 +21,7 @@ cmake_minimum_required(VERSION 2.8.2)
2121

2222
# Append the PROJECT_BINARY_DIR to CMAKE_PREFIX_PATH in order to be able to
2323
# find the configuration files at build time
24-
list(APPEND CMAKE_PREFIX_PATH ${PROJECT_BINARY_DIR})
24+
list(APPEND CMAKE_PREFIX_PATH ${PROJECT_BINARY_DIR}/src)
2525

2626
# c++ examples
2727
add_subdirectory(c++)

examples/c++/CMakeLists.txt.shared

Lines changed: 5 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -6,10 +6,11 @@ get_filename_component(example_name ${CMAKE_CURRENT_SOURCE_DIR} NAME)
66
project(${example_name})
77

88
# Let's require mutation++. It should export a suitable config that also
9-
# exports include directories for Eigen
10-
find_package(mutation++ REQUIRED)
11-
if (NOT mutation++_FOUND)
12-
message(FATAL_ERROR "mutation++ not found")
9+
# exports include directories for Eigen. The `if` is needed to allow the
10+
# examples to build during the process of building the entire mutation++
11+
# tree.
12+
if(NOT TARGET mutation++)
13+
find_package(mutation++ REQUIRED)
1314
endif()
1415

1516
add_executable(${example_name} ${example_name}.cpp)

src/CMakeLists.txt

Lines changed: 20 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -19,8 +19,6 @@
1919
# <http://www.gnu.org/licenses/>.
2020
#
2121

22-
cmake_minimum_required(VERSION 2.6)
23-
2422
#- Add sources for a target
2523
#
2624
# ADD_SOURCES(<target> <source1> [<source2> ...])
@@ -108,18 +106,6 @@ endif()
108106

109107
# Install and export targets
110108
include(GNUInstallDirs)
111-
install(TARGETS mutation++ EXPORT mutation++Targets
112-
LIBRARY DESTINATION ${CMAKE_INSTALL_LIBDIR}
113-
ARCHIVE DESTINATION ${CMAKE_INSTALL_LIBDIR}
114-
RUNTIME DESTINATION ${CMAKE_INSTALL_BINDIR}
115-
INCLUDES DESTINATION ${CMAKE_INSTALL_INCLUDEDIR}
116-
)
117-
118-
install(EXPORT mutation++Targets
119-
FILE mutation++Targets.cmake
120-
NAMESPACE mutation++::
121-
DESTINATION "${CMAKE_INSTALL_LIBDIR}/cmake/mutation++"
122-
)
123109

124110
# Version configuration file
125111
include(CMakePackageConfigHelpers)
@@ -146,3 +132,23 @@ install(FILES
146132
"${CMAKE_CURRENT_BINARY_DIR}/mutation++ConfigVersion.cmake"
147133
DESTINATION ${CMAKE_INSTALL_LIBDIR}/cmake/mutation++
148134
)
135+
136+
137+
install(TARGETS mutation++ EXPORT mutation++Targets
138+
LIBRARY DESTINATION ${CMAKE_INSTALL_LIBDIR}
139+
ARCHIVE DESTINATION ${CMAKE_INSTALL_LIBDIR}
140+
RUNTIME DESTINATION ${CMAKE_INSTALL_BINDIR}
141+
INCLUDES DESTINATION ${CMAKE_INSTALL_INCLUDEDIR}
142+
)
143+
144+
export(EXPORT mutation++Targets
145+
FILE mutation++Targets.cmake
146+
NAMESPACE mutation++::
147+
)
148+
149+
install(EXPORT mutation++Targets
150+
FILE mutation++Targets.cmake
151+
NAMESPACE mutation++::
152+
DESTINATION "${CMAKE_INSTALL_LIBDIR}/cmake/mutation++"
153+
EXPORT_LINK_INTERFACE_LIBRARIES
154+
)

src/general/CMakeLists.txt

Lines changed: 6 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -20,6 +20,7 @@
2020
#
2121

2222
cmake_minimum_required(VERSION 2.6)
23+
cmake_policy(SET CMP0022 NEW)
2324

2425
add_sources(mutation++
2526
Mixture.cpp
@@ -43,10 +44,11 @@ foreach (exe ${mutation++_exes})
4344
PRIVATE
4445
mutation++
4546
)
46-
install(
47-
TARGETS ${exe}
48-
EXPORT mutation++Targets
49-
RUNTIME DESTINATION "${INSTALL_BIN_DIR}" COMPONENT bin)
47+
# install(
48+
# TARGETS ${exe}
49+
# EXPORT mutation++Targets
50+
# RUNTIME DESTINATION "${INSTALL_BIN_DIR}"
51+
#)
5052
endforeach(exe ${mutation++_exes})
5153

5254

0 commit comments

Comments
 (0)