root/CMakeLists.txt

Revision 051aa57c86df0f479b52f2d82302feaf1f864628, 3.4 kB (checked in by David C. Lonie <david.lonie@…>, 8 days ago)

Windows fixes.

  • Property mode set to 100644
Line 
1project(XtalOpt)
2
3cmake_minimum_required(VERSION 2.6)
4set(CMAKE_MODULE_PATH ${XtalOpt_SOURCE_DIR}/cmake/modules)
5
6set(QT_MIN_VERSION "4.6.0")
7find_package(Qt4 REQUIRED)
8find_package(OpenBabel2 REQUIRED)
9find_package(Avogadro REQUIRED)
10
11include(${Avogadro_USE_FILE})
12include_directories( ${CMAKE_CURRENT_BINARY_DIR}
13                     ${OPENBABEL2_INCLUDE_DIR}
14                     ${XtalOpt_SOURCE_DIR}/src/)
15
16link_directories(${OPENBABEL2_LIBRARIES_DIRS})
17include(MacroEnsureVersion)
18
19option( BUILD_TESTS
20        "Whether to compile the test suite as well as the main code."
21        OFF )
22
23if(BUILD_TESTS)
24   enable_testing()
25endif(BUILD_TESTS)
26
27option( ENABLE_SSH
28        "Enable SSH. Only the local queue interface will be available if disabled."
29        ON )
30
31option( USE_CLI_SSH
32        "Use command line ssh/scp commands for remote communication. Use this if on linux/mac and Kerberos authentication is needed."
33        OFF )
34
35if(ENABLE_SSH)
36  add_definitions(-DENABLE_SSH)
37  message(STATUS "SSH Enabled")
38  # Pull in libssh
39  if(USE_CLI_SSH)
40    add_definitions(-DUSE_CLI_SSH)
41    message(STATUS "Using command-line SSH interface")
42  else(USE_CLI_SSH)
43    message(STATUS "Using libssh SSH interface")
44    set(LibSSH_FIND_VERSION ON)
45    set(LibSSH_MIN_VERSION "0.4.8")
46    find_package(LibSSH REQUIRED)
47    if(NOT LIBSSH_FOUND)
48      message(FATAL_ERROR "libssh not found!")
49    endif()
50    macro_ensure_version(${LibSSH_MIN_VERSION} ${LibSSH_VERSION}
51                         LIBSSH_VERSION_OK)
52    if(NOT LIBSSH_VERSION_OK)
53      message(FATAL_ERROR
54      "libssh too old! Installed version is ${LibSSH_VERSION}, need at least "
55      "libssh ${LibSSH_MIN_VERSION}")
56    endif()
57    message(STATUS "LibSSH found: ${LibSSH_VERSION} ${LIBSSH_INCLUDE_DIRS} ${LIBSSH_LIBRARIES}")
58    include_directories(${LIBSSH_INCLUDE_DIRS})
59  endif(USE_CLI_SSH)
60endif()
61
62# This is a modified version of the avogadro_plugin function that produces
63# a SHARED library instead of a MODULE
64function(process_plugin plugin_name src_list)
65  string(REPLACE ".cpp" ".h" hdr_list "${src_list}")
66  qt4_wrap_cpp(moc_files ${hdr_list})
67  if(NOT "${ARGV2}" STREQUAL "")
68    # Process the UI file for this plugin
69    qt4_wrap_ui(plugin_UIS_H ${ARGV2})
70  endif(NOT "${ARGV2}" STREQUAL "")
71  if(NOT "${ARGV3}" STREQUAL "")
72    # Process the RC file and add it to the plugin
73    qt4_add_resources(plugin_RC_SRCS ${ARGV3})
74  endif(NOT "${ARGV3}" STREQUAL "")
75  # Build static lib for linking to tests
76  if(BUILD_TESTS)
77    add_library(${plugin_name}_static STATIC ${src_list} ${plugin_UIS_H}
78                ${plugin_RC_SRCS} ${moc_files})
79    target_link_libraries(${plugin_name}_static avogadro)
80  endif(BUILD_TESTS)
81  add_library(${plugin_name} SHARED ${src_list} ${plugin_UIS_H}
82              ${plugin_RC_SRCS} ${moc_files})
83  target_link_libraries(${plugin_name} avogadro)
84
85  install(TARGETS ${plugin_name} DESTINATION "${Avogadro_PLUGIN_DIR}/contrib")
86
87  set_target_properties(${plugin_name} PROPERTIES
88                        OUTPUT_NAME ${plugin_name}
89                        PREFIX "")
90endfunction(process_plugin)
91
92# Set -fPIC on x86_64
93if("${CMAKE_SYSTEM_PROCESSOR}" STREQUAL "x86_64")
94  set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -fPIC"  )
95  set(CMAKE_C_FLAGS "${CMAKE_C_FLAGS} -fPIC"  )
96endif("${CMAKE_SYSTEM_PROCESSOR}" STREQUAL "x86_64")
97
98# USING_DYNAMIC_LIBS needs to be defined for OpenBabel to properly export some symbols
99if (MSVC)
100  add_definitions(-DUSING_DYNAMIC_LIBS)
101endif (MSVC)
102
103add_subdirectory(src)
104
105if(BUILD_TESTS)
106  add_subdirectory(tests)
107endif(BUILD_TESTS)
Note: See TracBrowser for help on using the browser.