summaryrefslogtreecommitdiff
path: root/src/lib/CMakeLists.txt
diff options
context:
space:
mode:
authorMark Abraham <mark.j.abraham@gmail.com>2014-06-16 09:53:30 (GMT)
committerGerrit Code Review <gerrit@gerrit.gromacs.org>2014-06-16 13:52:30 (GMT)
commit4019fd9081241aca8a054252fcb5654297888a38 (patch)
tree5d8d7957755e019ea262d2d36ca9b175d9ac803c /src/lib/CMakeLists.txt
parentf38717324267c2da69c20a0f1918ce8ef1e66be7 (diff)
Enhancements to CMake usage
These changes mostly address being able to use fully-constructed source-file targets in GROMACS, e.g. to construct an object library. Thus compilation properties are moved onto the source files, rather than the library into which they are linked. Removed unnecessary library properties Made it easier to handle lists of source files in non-repetitious ways. Change-Id: I01a4a56ba8a8d45ba02d95d08c948b9ca5015013
Diffstat (limited to 'src/lib/CMakeLists.txt')
-rw-r--r--src/lib/CMakeLists.txt31
1 files changed, 17 insertions, 14 deletions
diff --git a/src/lib/CMakeLists.txt b/src/lib/CMakeLists.txt
index c760f57..81b5843 100644
--- a/src/lib/CMakeLists.txt
+++ b/src/lib/CMakeLists.txt
@@ -1,18 +1,18 @@
+set(source_files tng_io.c md5.c)
if(TNG_BUILD_FORTRAN)
- add_library(tng_io tng_io.c md5.c tng_io_fortran.c)
-else()
- add_library(tng_io tng_io.c md5.c)
+ list(APPEND source_files tng_io_fortran.c)
endif()
-set_property(TARGET tng_io PROPERTY LIBRARY_OUTPUT_DIRECTORY ${CMAKE_LIBRARY_OUTPUT_DIRECTORY})
-set_property(TARGET tng_io PROPERTY ARCHIVE_OUTPUT_DIRECTORY ${CMAKE_LIBRARY_OUTPUT_DIRECTORY})
+add_library(tng_io ${source_files})
-install(TARGETS tng_io
- LIBRARY DESTINATION lib
- ARCHIVE DESTINATION lib)
+# Now add source-file compilation properties to the source-file
+# targets
if(HAVE_INTTYPES_H)
- set_property(TARGET tng_io APPEND PROPERTY COMPILE_DEFINITIONS USE_STD_INTTYPES_H)
+ set_property(SOURCE tng_io.c APPEND PROPERTY COMPILE_DEFINITIONS USE_STD_INTTYPES_H)
+endif()
+if(TNG_BUILD_WITH_ZLIB)
+ set_property(SOURCE tng_io.c APPEND PROPERTY COMPILE_DEFINITIONS USE_ZLIB)
endif()
# This test is for md5. The TNG library itself determines the actual byte order -
@@ -20,12 +20,15 @@ endif()
include(TestBigEndian)
test_big_endian(TNG_INTEGER_BIG_ENDIAN)
if(TNG_INTEGER_BIG_ENDIAN)
- set_property(TARGET tng_io APPEND PROPERTY COMPILE_DEFINITIONS TNG_INTEGER_BIG_ENDIAN)
+ set_property(SOURCE md5.c APPEND PROPERTY COMPILE_DEFINITIONS TNG_INTEGER_BIG_ENDIAN)
endif()
+# Append the required library dependencies
+target_link_libraries(tng_io tng_compress)
if(TNG_BUILD_WITH_ZLIB)
- set_property(TARGET tng_io APPEND PROPERTY COMPILE_DEFINITIONS USE_ZLIB)
- target_link_libraries(tng_io tng_compress ${ZLIB_LIBRARIES})
-else()
- target_link_libraries(tng_io tng_compress)
+ target_link_libraries(tng_io ${ZLIB_LIBRARIES})
endif()
+
+install(TARGETS tng_io
+ LIBRARY DESTINATION lib
+ ARCHIVE DESTINATION lib)
contact: Jan Huwald // Impressum