Skip to content

Commit 918dafe

Browse files
iii-ivitalybuka
authored andcommitted
Fix building on Fedora
Use https://cmake.org/cmake/help/latest/module/GNUInstallDirs.html module for determining whether child CMake will install libraries into lib, lib64 or even somewhere else. Fixes #131
1 parent 8942a9b commit 918dafe

File tree

2 files changed

+9
-5
lines changed

2 files changed

+9
-5
lines changed

cmake/external/googletest.cmake

Lines changed: 5 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -12,6 +12,8 @@
1212
# See the License for the specific language governing permissions and
1313
# limitations under the License.
1414

15+
include(GNUInstallDirs)
16+
1517
set(GTEST_TARGET external.googletest)
1618
set(GTEST_INSTALL_DIR ${CMAKE_CURRENT_BINARY_DIR}/${GTEST_TARGET})
1719

@@ -25,12 +27,12 @@ set(GTEST_BOTH_LIBRARIES ${GTEST_LIBRARIES} ${GTEST_MAIN_LIBRARIES})
2527
foreach(lib IN LISTS GTEST_BOTH_LIBRARIES)
2628
if (MSVC)
2729
if (CMAKE_BUILD_TYPE MATCHES Debug)
28-
set(LIB_PATH ${GTEST_INSTALL_DIR}/lib/${lib}d.lib)
30+
set(LIB_PATH ${GTEST_INSTALL_DIR}/${CMAKE_INSTALL_LIBDIR}/${lib}d.lib)
2931
else()
30-
set(LIB_PATH ${GTEST_INSTALL_DIR}/lib/${lib}.lib)
32+
set(LIB_PATH ${GTEST_INSTALL_DIR}/${CMAKE_INSTALL_LIBDIR}/${lib}.lib)
3133
endif()
3234
else()
33-
set(LIB_PATH ${GTEST_INSTALL_DIR}/lib/lib${lib}.a)
35+
set(LIB_PATH ${GTEST_INSTALL_DIR}/${CMAKE_INSTALL_LIBDIR}/lib${lib}.a)
3436
endif()
3537
list(APPEND GTEST_BUILD_BYPRODUCTS ${LIB_PATH})
3638

cmake/external/protobuf.cmake

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -12,6 +12,8 @@
1212
# See the License for the specific language governing permissions and
1313
# limitations under the License.
1414

15+
include(GNUInstallDirs)
16+
1517
# We only need protobuf_generate_cpp from FindProtobuf, and we are going to
1618
# override the rest with ExternalProject version.
1719
include (FindProtobuf)
@@ -31,9 +33,9 @@ ENDIF()
3133

3234
foreach(lib ${PROTOBUF_LIBRARIES})
3335
if (MSVC)
34-
set(LIB_PATH ${PROTOBUF_INSTALL_DIR}/lib/lib${lib}.lib)
36+
set(LIB_PATH ${PROTOBUF_INSTALL_DIR}/${CMAKE_INSTALL_LIBDIR}/lib${lib}.lib)
3537
else()
36-
set(LIB_PATH ${PROTOBUF_INSTALL_DIR}/lib/lib${lib}.a)
38+
set(LIB_PATH ${PROTOBUF_INSTALL_DIR}/${CMAKE_INSTALL_LIBDIR}/lib${lib}.a)
3739
endif()
3840
list(APPEND PROTOBUF_BUILD_BYPRODUCTS ${LIB_PATH})
3941

0 commit comments

Comments
 (0)