Skip to content
GitLab
Explore
Sign in
Primary navigation
Search or go to…
Project
L
lammps
Manage
Activity
Members
Labels
Plan
Issues
Issue boards
Milestones
Wiki
Code
Merge requests
Repository
Branches
Commits
Tags
Repository graph
Compare revisions
Snippets
Build
Pipelines
Jobs
Pipeline schedules
Artifacts
Deploy
Releases
Container Registry
Model registry
Operate
Environments
Monitor
Incidents
Analyze
Value stream analytics
Contributor analytics
CI/CD analytics
Repository analytics
Model experiments
Help
Help
Support
GitLab documentation
Compare GitLab plans
Community forum
Contribute to GitLab
Provide feedback
Keyboard shortcuts
?
Snippets
Groups
Projects
Show more breadcrumbs
multiscale
lammps
Commits
3f17d33f
Commit
3f17d33f
authored
6 years ago
by
Christoph Junghans
Browse files
Options
Downloads
Patches
Plain Diff
cmake: add BUILD_LIB option
parent
ac41cc2c
No related branches found
Branches containing commit
No related tags found
No related merge requests found
Changes
1
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
cmake/CMakeLists.txt
+38
-18
38 additions, 18 deletions
cmake/CMakeLists.txt
with
38 additions
and
18 deletions
cmake/CMakeLists.txt
+
38
−
18
View file @
3f17d33f
...
@@ -57,9 +57,17 @@ endif()
...
@@ -57,9 +57,17 @@ endif()
########################################################################
########################################################################
# User input options #
# User input options #
########################################################################
########################################################################
option
(
BUILD_SHARED_LIBS
"Build shared libs"
OFF
)
option
(
BUILD_LIB
"Build LAMMPS library"
OFF
)
if
(
BUILD_SHARED_LIBS
)
# for all pkg libs, mpi_stubs and linalg
if
(
BUILD_LIB
)
set
(
CMAKE_POSITION_INDEPENDENT_CODE ON
)
option
(
BUILD_SHARED_LIBS
"Build shared library"
OFF
)
if
(
BUILD_SHARED_LIBS
)
# for all pkg libs, mpi_stubs and linalg
set
(
CMAKE_POSITION_INDEPENDENT_CODE ON
)
endif
()
set
(
LIB_SUFFIX
""
CACHE STRING
"Suffix to append to liblammps and pkg-config file"
)
mark_as_advanced
(
LIB_SUFFIX
)
if
(
LIB_SUFFIX
)
set
(
LIB_SUFFIX
"_
${
LIB_SUFFIX
}
"
)
endif
()
endif
()
endif
()
option
(
DEVELOPER_MODE
"Enable developer mode"
OFF
)
option
(
DEVELOPER_MODE
"Enable developer mode"
OFF
)
mark_as_advanced
(
DEVELOPER_MODE
)
mark_as_advanced
(
DEVELOPER_MODE
)
...
@@ -102,7 +110,7 @@ if(LAMMPS_EXCEPTIONS)
...
@@ -102,7 +110,7 @@ if(LAMMPS_EXCEPTIONS)
set
(
LAMMPS_API_DEFINES
"
${
LAMMPS_API_DEFINES
}
-DLAMMPS_EXCEPTIONS"
)
set
(
LAMMPS_API_DEFINES
"
${
LAMMPS_API_DEFINES
}
-DLAMMPS_EXCEPTIONS"
)
endif
()
endif
()
set
(
LAMMPS_MACHINE
""
CACHE STRING
"Suffix to append to lmp binary
and liblammps
(WON'T enable any features automatically"
)
set
(
LAMMPS_MACHINE
""
CACHE STRING
"Suffix to append to lmp binary (WON'T enable any features automatically"
)
mark_as_advanced
(
LAMMPS_MACHINE
)
mark_as_advanced
(
LAMMPS_MACHINE
)
if
(
LAMMPS_MACHINE
)
if
(
LAMMPS_MACHINE
)
set
(
LAMMPS_MACHINE
"_
${
LAMMPS_MACHINE
}
"
)
set
(
LAMMPS_MACHINE
"_
${
LAMMPS_MACHINE
}
"
)
...
@@ -213,7 +221,7 @@ if(PKG_PYTHON)
...
@@ -213,7 +221,7 @@ if(PKG_PYTHON)
add_definitions
(
-DLMP_PYTHON
)
add_definitions
(
-DLMP_PYTHON
)
include_directories
(
${
PYTHON_INCLUDE_DIR
}
)
include_directories
(
${
PYTHON_INCLUDE_DIR
}
)
list
(
APPEND LAMMPS_LINK_LIBS
${
PYTHON_LIBRARY
}
)
list
(
APPEND LAMMPS_LINK_LIBS
${
PYTHON_LIBRARY
}
)
if
(
BUILD_SHARED_LIBS
)
if
(
BUILDLIB AND
BUILD_SHARED_LIBS
)
if
(
NOT PYTHON_INSTDIR
)
if
(
NOT PYTHON_INSTDIR
)
execute_process
(
COMMAND
${
PYTHON_EXECUTABLE
}
execute_process
(
COMMAND
${
PYTHON_EXECUTABLE
}
-c
"import distutils.sysconfig as cg; print(cg.get_python_lib(1,0,prefix='
${
CMAKE_INSTALL_PREFIX
}
'))"
-c
"import distutils.sysconfig as cg; print(cg.get_python_lib(1,0,prefix='
${
CMAKE_INSTALL_PREFIX
}
'))"
...
@@ -800,28 +808,40 @@ include_directories(${LAMMPS_STYLE_HEADERS_DIR})
...
@@ -800,28 +808,40 @@ include_directories(${LAMMPS_STYLE_HEADERS_DIR})
###########################################
###########################################
# Actually add executable and lib to build
# Actually add executable and lib to build
############################################
############################################
add_library
(
lammps
${
LIB_SOURCES
}
)
get_property
(
LANGUAGES GLOBAL PROPERTY ENABLED_LANGUAGES
)
get_property
(
LANGUAGES GLOBAL PROPERTY ENABLED_LANGUAGES
)
list
(
FIND LANGUAGES
"Fortran"
_index
)
list
(
FIND LANGUAGES
"Fortran"
_index
)
if
(
${
_index
}
GREATER -1
)
if
(
${
_index
}
GREATER -1
)
list
(
APPEND LAMMPS_LINK_LIBS
${
CMAKE_Fortran_IMPLICIT_LINK_LIBRARIES
}
)
list
(
APPEND LAMMPS_LINK_LIBS
${
CMAKE_Fortran_IMPLICIT_LINK_LIBRARIES
}
)
endif
()
endif
()
list
(
REMOVE_DUPLICATES LAMMPS_LINK_LIBS
)
list
(
REMOVE_DUPLICATES LAMMPS_LINK_LIBS
)
target_link_libraries
(
lammps
${
LAMMPS_LINK_LIBS
}
)
if
(
BUILD_LIB
)
if
(
LAMMPS_DEPS
)
add_library
(
lammps
${
LIB_SOURCES
}
)
add_dependencies
(
lammps
${
LAMMPS_DEPS
}
)
target_link_libraries
(
lammps
${
LAMMPS_LINK_LIBS
}
)
endif
()
if
(
LAMMPS_DEPS
)
set_target_properties
(
lammps PROPERTIES OUTPUT_NAME lammps
${
LAMMPS_MACHINE
}
)
add_dependencies
(
lammps
${
LAMMPS_DEPS
}
)
if
(
BUILD_SHARED_LIBS
)
endif
()
set_target_properties
(
lammps PROPERTIES SOVERSION
${
SOVERSION
}
)
set_target_properties
(
lammps PROPERTIES OUTPUT_NAME lammps
${
LIB_SUFFIX
}
)
install
(
TARGETS lammps LIBRARY DESTINATION
${
CMAKE_INSTALL_LIBDIR
}
ARCHIVE DESTINATION
${
CMAKE_INSTALL_LIBDIR
}
)
if
(
BUILD_SHARED_LIBS
)
install
(
FILES
${
LAMMPS_SOURCE_DIR
}
/library.h DESTINATION
${
CMAKE_INSTALL_INCLUDEDIR
}
/lammps
)
set_target_properties
(
lammps PROPERTIES SOVERSION
${
SOVERSION
}
)
configure_file
(
pkgconfig/liblammps.pc.in
${
CMAKE_CURRENT_BINARY_DIR
}
/liblammps
${
LAMMPS_MACHINE
}
.pc @ONLY
)
install
(
TARGETS lammps LIBRARY DESTINATION
${
CMAKE_INSTALL_LIBDIR
}
ARCHIVE DESTINATION
${
CMAKE_INSTALL_LIBDIR
}
)
install
(
FILES
${
CMAKE_CURRENT_BINARY_DIR
}
/liblammps
${
LAMMPS_MACHINE
}
.pc DESTINATION
${
CMAKE_INSTALL_LIBDIR
}
/pkgconfig
)
install
(
FILES
${
LAMMPS_SOURCE_DIR
}
/library.h DESTINATION
${
CMAKE_INSTALL_INCLUDEDIR
}
/lammps
)
configure_file
(
pkgconfig/liblammps.pc.in
${
CMAKE_CURRENT_BINARY_DIR
}
/liblammps
${
LIB_SUFFIX
}
.pc @ONLY
)
install
(
FILES
${
CMAKE_CURRENT_BINARY_DIR
}
/liblammps
${
LIB_SUFFIX
}
.pc DESTINATION
${
CMAKE_INSTALL_LIBDIR
}
/pkgconfig
)
endif
()
else
()
list
(
APPEND LMP_SOURCES
${
LIB_SOURCES
}
)
endif
()
endif
()
add_executable
(
lmp
${
LMP_SOURCES
}
)
add_executable
(
lmp
${
LMP_SOURCES
}
)
target_link_libraries
(
lmp lammps
)
if
(
BUILD_LIB
)
target_link_libraries
(
lmp lammps
)
else
()
target_link_libraries
(
lmp
${
LAMMPS_LINK_LIBS
}
)
if
(
LAMMPS_DEPS
)
add_dependencies
(
lmp
${
LAMMPS_DEPS
}
)
endif
()
endif
()
set_target_properties
(
lmp PROPERTIES OUTPUT_NAME lmp
${
LAMMPS_MACHINE
}
)
set_target_properties
(
lmp PROPERTIES OUTPUT_NAME lmp
${
LAMMPS_MACHINE
}
)
install
(
TARGETS lmp DESTINATION
${
CMAKE_INSTALL_BINDIR
}
)
install
(
TARGETS lmp DESTINATION
${
CMAKE_INSTALL_BINDIR
}
)
if
(
ENABLE_TESTING
)
if
(
ENABLE_TESTING
)
...
...
This diff is collapsed.
Click to expand it.
Preview
0%
Loading
Try again
or
attach a new file
.
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Save comment
Cancel
Please
register
or
sign in
to comment