forked from lijiext/lammps
add workaround in CMake support for building with MinGW cross-compilers
This commit is contained in:
parent
3bd529342e
commit
b1af0a5bd8
|
@ -35,6 +35,8 @@ if(PKG_KIM)
|
||||||
option(DOWNLOAD_KIM "Download KIM-API from OpenKIM instead of using an already installed one" ${DOWNLOAD_KIM_DEFAULT})
|
option(DOWNLOAD_KIM "Download KIM-API from OpenKIM instead of using an already installed one" ${DOWNLOAD_KIM_DEFAULT})
|
||||||
if(DOWNLOAD_KIM)
|
if(DOWNLOAD_KIM)
|
||||||
message(STATUS "KIM-API download requested - we will build our own")
|
message(STATUS "KIM-API download requested - we will build our own")
|
||||||
|
# Workaround for cross compilation with MinGW, which messes up ${CMAKE_INSTALL_LIBDIR}
|
||||||
|
string(REPLACE ${CMAKE_INSTALL_PREFIX} "" _KIM_LIBDIR ${CMAKE_INSTALL_LIBDIR})
|
||||||
include(ExternalProject)
|
include(ExternalProject)
|
||||||
enable_language(C)
|
enable_language(C)
|
||||||
enable_language(Fortran)
|
enable_language(Fortran)
|
||||||
|
@ -50,11 +52,11 @@ if(PKG_KIM)
|
||||||
-DCMAKE_BUILD_TYPE=${CMAKE_BUILD_TYPE}
|
-DCMAKE_BUILD_TYPE=${CMAKE_BUILD_TYPE}
|
||||||
-DCMAKE_MAKE_PROGRAM=${CMAKE_MAKE_PROGRAM}
|
-DCMAKE_MAKE_PROGRAM=${CMAKE_MAKE_PROGRAM}
|
||||||
-DCMAKE_TOOLCHAIN_FILE=${CMAKE_TOOLCHAIN_FILE}
|
-DCMAKE_TOOLCHAIN_FILE=${CMAKE_TOOLCHAIN_FILE}
|
||||||
BUILD_BYPRODUCTS <INSTALL_DIR>/${CMAKE_INSTALL_LIBDIR}/libkim-api${CMAKE_SHARED_LIBRARY_SUFFIX}
|
BUILD_BYPRODUCTS <INSTALL_DIR>/${_KIM_LIBDIR}/libkim-api${CMAKE_SHARED_LIBRARY_SUFFIX}
|
||||||
)
|
)
|
||||||
ExternalProject_get_property(kim_build INSTALL_DIR)
|
ExternalProject_get_property(kim_build INSTALL_DIR)
|
||||||
set(KIM-API_INCLUDE_DIRS ${INSTALL_DIR}/include/kim-api)
|
set(KIM-API_INCLUDE_DIRS ${INSTALL_DIR}/include/kim-api)
|
||||||
set(KIM-API_LDFLAGS ${INSTALL_DIR}/${CMAKE_INSTALL_LIBDIR}/libkim-api${CMAKE_SHARED_LIBRARY_SUFFIX})
|
set(KIM-API_LDFLAGS ${INSTALL_DIR}/${_KIM_LIBDIR}/libkim-api${CMAKE_SHARED_LIBRARY_SUFFIX})
|
||||||
list(APPEND LAMMPS_DEPS kim_build)
|
list(APPEND LAMMPS_DEPS kim_build)
|
||||||
else()
|
else()
|
||||||
find_package(KIM-API ${KIM-API_MIN_VERSION} REQUIRED)
|
find_package(KIM-API ${KIM-API_MIN_VERSION} REQUIRED)
|
||||||
|
|
|
@ -9,6 +9,8 @@ if(PKG_LATTE)
|
||||||
option(DOWNLOAD_LATTE "Download the LATTE library instead of using an already installed one" ${DOWNLOAD_LATTE_DEFAULT})
|
option(DOWNLOAD_LATTE "Download the LATTE library instead of using an already installed one" ${DOWNLOAD_LATTE_DEFAULT})
|
||||||
if(DOWNLOAD_LATTE)
|
if(DOWNLOAD_LATTE)
|
||||||
message(STATUS "LATTE download requested - we will build our own")
|
message(STATUS "LATTE download requested - we will build our own")
|
||||||
|
# Workaround for cross compilation with MinGW, which messes up ${CMAKE_INSTALL_LIBDIR}
|
||||||
|
string(REPLACE ${CMAKE_INSTALL_PREFIX} "" _LATTE_LIBDIR ${CMAKE_INSTALL_LIBDIR})
|
||||||
include(ExternalProject)
|
include(ExternalProject)
|
||||||
ExternalProject_Add(latte_build
|
ExternalProject_Add(latte_build
|
||||||
URL https://github.com/lanl/LATTE/archive/v1.2.1.tar.gz
|
URL https://github.com/lanl/LATTE/archive/v1.2.1.tar.gz
|
||||||
|
@ -18,17 +20,20 @@ if(PKG_LATTE)
|
||||||
-DBLAS_LIBRARIES=${BLAS_LIBRARIES} -DLAPACK_LIBRARIES=${LAPACK_LIBRARIES}
|
-DBLAS_LIBRARIES=${BLAS_LIBRARIES} -DLAPACK_LIBRARIES=${LAPACK_LIBRARIES}
|
||||||
-DCMAKE_Fortran_COMPILER=${CMAKE_Fortran_COMPILER} -DCMAKE_Fortran_FLAGS=${CMAKE_Fortran_FLAGS}
|
-DCMAKE_Fortran_COMPILER=${CMAKE_Fortran_COMPILER} -DCMAKE_Fortran_FLAGS=${CMAKE_Fortran_FLAGS}
|
||||||
-DCMAKE_Fortran_FLAGS_${BTYPE}=${CMAKE_Fortran_FLAGS_${BTYPE}} -DCMAKE_BUILD_TYPE=${CMAKE_BUILD_TYPE}
|
-DCMAKE_Fortran_FLAGS_${BTYPE}=${CMAKE_Fortran_FLAGS_${BTYPE}} -DCMAKE_BUILD_TYPE=${CMAKE_BUILD_TYPE}
|
||||||
-DCMAKE_MAKE_PROGRAM=${CMAKE_MAKE_PROGRAM}
|
-DCMAKE_MAKE_PROGRAM=${CMAKE_MAKE_PROGRAM} -DCMAKE_TOOLCHAIN_FILE=${CMAKE_TOOLCHAIN_FILE}
|
||||||
BUILD_BYPRODUCTS <INSTALL_DIR>/${CMAKE_INSTALL_LIBDIR}/liblatte.a
|
BUILD_BYPRODUCTS <INSTALL_DIR>/${_LATTE_LIBDIR}/liblatte.a
|
||||||
)
|
)
|
||||||
ExternalProject_get_property(latte_build INSTALL_DIR)
|
|
||||||
set(LATTE_LIBRARIES ${INSTALL_DIR}/${CMAKE_INSTALL_LIBDIR}/liblatte.a)
|
|
||||||
list(APPEND LAMMPS_DEPS latte_build)
|
list(APPEND LAMMPS_DEPS latte_build)
|
||||||
|
ExternalProject_get_property(latte_build INSTALL_DIR)
|
||||||
|
set(LATTE_LIBRARIES ${INSTALL_DIR}/${_LATTE_LIBDIR}/liblatte.a)
|
||||||
else()
|
else()
|
||||||
find_package(LATTE)
|
find_package(LATTE)
|
||||||
if(NOT LATTE_FOUND)
|
if(NOT LATTE_FOUND)
|
||||||
message(FATAL_ERROR "LATTE library not found, help CMake to find it by setting LATTE_LIBRARY, or set DOWNLOAD_LATTE=ON to download it")
|
message(FATAL_ERROR "LATTE library not found, help CMake to find it by setting LATTE_LIBRARY, or set DOWNLOAD_LATTE=ON to download it")
|
||||||
endif()
|
endif()
|
||||||
endif()
|
endif()
|
||||||
|
if(NOT LAPACK_FOUND)
|
||||||
|
add_dependencies(latte_build linalg)
|
||||||
|
endif()
|
||||||
list(APPEND LAMMPS_LINK_LIBS ${LATTE_LIBRARIES} ${LAPACK_LIBRARIES})
|
list(APPEND LAMMPS_LINK_LIBS ${LATTE_LIBRARIES} ${LAPACK_LIBRARIES})
|
||||||
endif()
|
endif()
|
||||||
|
|
Loading…
Reference in New Issue