add an option to not build the template
authorChristoph Junghans <junghans@votca.org>
Fri, 21 Dec 2012 18:23:14 +0000 (11:23 -0700)
committerGerrit Code Review <gerrit@gerrit.gromacs.org>
Thu, 3 Jan 2013 18:49:41 +0000 (19:49 +0100)
Change-Id: Ia85fc9dfbd191ac66cfff2d7b7c815620d800afe

share/template/CMakeLists.txt

index b205633cf5fc4eb7d4aed9fb464541d78238120d..a4ace20c75582bcb0164f9095be653b3902f757c 100644 (file)
@@ -43,12 +43,23 @@ add_custom_command(OUTPUT gromacs
     DEPENDS ${GROMACS_HEADERS})
 add_custom_target(gromacs_include_links DEPENDS gromacs)
 
-add_executable(template template.c)
-remove_definitions( -DHAVE_CONFIG_H )
-add_definitions("${PKG_CFLAGS}")
-target_link_libraries(template gmx)
-include_directories("${CMAKE_CURRENT_BINARY_DIR}")
-add_dependencies(template gromacs_include_links)
+option(GMX_BUILD_TEMPLATE "Build gromacs template program" ON)
+mark_as_advanced(GMX_BUILD_TEMPLATE)
+# GMX_PREFER_STATIC_OPENMP=yes is a special case to build binaries
+# to distribute and as the template is not installed it can be
+# ignored.
+# The template is build in a user-like environment, hence we use
+# flags from PKG_CFLAGS. Again GMX_PREFER_STATIC_OPENMP=yes would
+# need special link flags (OpenMP_LINKER_FLAGS), which are not
+# very user-like.
+if (GMX_BUILD_TEMPLATE AND NOT GMX_PREFER_STATIC_OPENMP)
+    add_executable(template template.c)
+    remove_definitions( -DHAVE_CONFIG_H )
+    add_definitions("${PKG_CFLAGS}")
+    target_link_libraries(template gmx)
+    include_directories("${CMAKE_CURRENT_BINARY_DIR}")
+    add_dependencies(template gromacs_include_links)
+endif()
 
 install(FILES README template.c Makefile.pkg
         DESTINATION ${DATA_INSTALL_DIR}/template