this repo has no description
1# 2# Main authors: 3# Vincent Barichard <Vincent.Barichard@univ-angers.fr> 4# 5# Copyright: 6# Vincent Barichard, 2013 7# 8# Last modified: 9# $Date$ by $Author$ 10# $Revision$ 11# 12# This file is part of Quacode: 13# http://quacode.barichard.com 14# 15# Permission is hereby granted, free of charge, to any person obtaining 16# a copy of this software and associated documentation files (the 17# "Software"), to deal in the Software without restriction, including 18# without limitation the rights to use, copy, modify, merge, publish, 19# distribute, sublicense, and/or sell copies of the Software, and to 20# permit persons to whom the Software is furnished to do so, subject to 21# the following conditions: 22# 23# The above copyright notice and this permission notice shall be 24# included in all copies or substantial portions of the Software. 25# 26# THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, 27# EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF 28# MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND 29# NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE 30# LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION 31# OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION 32# WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. 33# 34 35CMAKE_MINIMUM_REQUIRED(VERSION 2.8) 36 37SET(GECODE_SRC "${CMAKE_SOURCE_DIR}/../.." CACHE PATH "Path where GeCode source is installed") 38SET(GECODE_BIN "${GECODE_SRC}" CACHE PATH "Path where GeCode libs and binaries are installed") 39SET(BUILD_EXAMPLES ON CACHE BOOL "Build examples or not") 40 41# If the user specifies -DCMAKE_BUILD_TYPE on the command line, take their definition 42# and dump it in the cache along with proper documentation, otherwise set CMAKE_BUILD_TYPE 43# to Debug prior to calling PROJECT() 44# 45IF(NOT DEFINED CMAKE_BUILD_TYPE) 46 # Check if Gecode is configured with --enable-debug 47 FILE(STRINGS ${GECODE_BIN}/config.status GECODE_DEBUG_BUILD REGEX "S\\[\"DEBUG_BUILD\"\\]=") 48 IF(GECODE_DEBUG_BUILD MATCHES "yes") 49 SET(QUACODE_BUILD_TYPE "Debug") 50 ELSE() 51 SET(QUACODE_BUILD_TYPE "Release") 52 ENDIF() 53 54 SET(CMAKE_BUILD_TYPE "${QUACODE_BUILD_TYPE}" CACHE STRING "Choose the type of build, options are: None(CMAKE_CXX_FLAGS or CMAKE_C_FLAGS used) Debug Release RelWithDebInfo MinSizeRel.") 55ENDIF() 56 57PROJECT(Quacode) 58SET(CMAKE_CXX_FLAGS "-std=c++11") 59 60SET(CMAKE_VERBOSE_MAKEFILE TRUE) 61 62# Check if Gecode is configured with --enable-audit 63FILE(STRINGS ${GECODE_BIN}/config.status GECODE_AUDIT REGEX "D\\[\"GECODE_AUDIT\"\\]=") 64IF(GECODE_AUDIT) 65 SET(QUACODE_AUDIT TRUE) 66ELSE() 67 SET(QUACODE_AUDIT FALSE) 68ENDIF() 69SET(LOG_AUDIT ${QUACODE_AUDIT} CACHE BOOL "Set to true to generate log output.") 70 71IF(UNIX) 72 # determine, whether we want a static binary 73 SET(STATIC_LINKING FALSE CACHE BOOL "Build a static binary?") 74 # do we want static libraries? 75 IF(STATIC_LINKING) 76 SET(BUILD_SHARED_LIBS OFF) 77 # To know in source file that we compil static 78 ADD_DEFINITIONS(-DQUACODE_STATIC_LIBS) 79 # When STATIC_LINKING is TRUE, than cmake looks for libraries ending 80 # with .a. This is for linux only! 81 SET(CMAKE_FIND_LIBRARY_SUFFIXES ".a") 82 SET(CMAKE_EXE_LINKER_FLAGS "-static") 83 # Remove flags to get rid off all the -Wl,Bydnamic 84 SET(CMAKE_EXE_LINK_DYNAMIC_C_FLAGS) 85 SET(CMAKE_EXE_LINK_DYNAMIC_CXX_FLAGS) 86 # Use static libs for Boost 87 SET(Boost_USE_STATIC_LIBS ON) 88 SET(Boost_USE_STATIC_RUNTIME ON) 89 ELSE(STATIC_LINKING) 90 SET(BUILD_SHARED_LIBS ON) 91 ENDIF(STATIC_LINKING) 92ELSE(UNIX) 93 SET(BUILD_SHARED_LIBS ON) 94ENDIF(UNIX) 95 96SET(CMAKE_MODULE_PATH ${CMAKE_CURRENT_SOURCE_DIR} ${CMAKE_MODULE_PATH}) 97FIND_PACKAGE(Gecode) 98 99IF(NOT GECODE_FOUND) 100 MESSAGE(FATAL_ERROR "Gecode is needed, consider to install it") 101ELSE (NOT GECODE_FOUND) 102 INCLUDE_DIRECTORIES(${CMAKE_CURRENT_BINARY_DIR}) 103 INCLUDE_DIRECTORIES(${GECODE_BIN}) 104 INCLUDE_DIRECTORIES(${CMAKE_CURRENT_SOURCE_DIR}) 105 INCLUDE_DIRECTORIES(${GECODE_SRC}) 106 107 LINK_DIRECTORIES(${CMAKE_CURRENT_BINARY_DIR}) 108 LINK_DIRECTORIES(${GECODE_BIN}) 109 110 IF (CMAKE_COMPILER_IS_GNUCXX) 111 ADD_DEFINITIONS(-Wall) 112 ADD_DEFINITIONS(-Wextra) 113 ADD_DEFINITIONS(-Wno-unused-local-typedefs) 114 ADD_DEFINITIONS(-fimplement-inlines) 115 ADD_DEFINITIONS(-fno-inline-functions) 116 ADD_DEFINITIONS(-pipe) 117 ADD_DEFINITIONS(-fPIC) 118 SET(CMAKE_CXX_FLAGS_DEBUG "-ggdb") 119 ENDIF () 120 121 IF (LOG_AUDIT) 122 ADD_DEFINITIONS(-DLOG_AUDIT) 123 ENDIF() 124 125 INCLUDE(CheckCXXCompilerFlag) 126 check_cxx_compiler_flag(-fvisibility=hidden HAVE_VISIBILITY_HIDDEN_FLAG) 127 IF (HAVE_VISIBILITY_HIDDEN_FLAG) 128 ADD_DEFINITIONS(-fvisibility=hidden) 129 ADD_DEFINITIONS(-DQUACODE_GCC_HAS_CLASS_VISIBILITY) 130 ENDIF() 131 132 FIND_PACKAGE(Threads) 133 134 SET(QUACODE_HEADERS 135 quacode/qcsp.hh 136 quacode/qspaceinfo.hh 137 quacode/support/dynamic-list.hh 138 quacode/support/log.hh 139 quacode/search/sequential/qpath.hh 140 quacode/search/sequential/qdfs.hh 141 quacode/qint/qbool.hh 142 ) 143 SET(QUACODE_HPP 144 quacode/qspaceinfo.hpp 145 quacode/search/qdfs.hpp 146 quacode/qint/watch.hpp 147 quacode/qint/qbool/clause.hpp 148 quacode/qint/qbool/eq.hpp 149 quacode/qint/qbool/eqv.hpp 150 quacode/qint/qbool/or.hpp 151 quacode/qint/qbool/xor.hpp 152 quacode/qint/qbool/xorv.hpp 153 ) 154 SET(QUACODE_SRCS 155 quacode/qspaceinfo.cpp 156 quacode/support/log.cpp 157 quacode/search/qdfs.cpp 158 quacode/search/sequential/qpath.cpp 159 quacode/qint/qbool/qbool.cpp 160 ${GECODE_SRC}/gecode/search/meta/nogoods.cpp 161 ) 162 SET(QUACODE_EXAMPLES_SRCS 163 examples/qbf.cpp 164 examples/qdimacs.cpp 165 examples/nim-fibo.cpp 166 examples/matrix-game.cpp 167 examples/connect-four.cpp 168 examples/baker.cpp 169 examples/rndQCSP.cpp 170 ) 171 172 SOURCE_GROUP("Hpp Files" REGULAR_EXPRESSION ".hpp") 173 174 SET_SOURCE_FILES_PROPERTIES(${ALL_HEADERS} PROPERTIES HEADER_FILE_ONLY TRUE) 175 SET_SOURCE_FILES_PROPERTIES(${ALL_HPP} PROPERTIES HEADER_FILE_ONLY TRUE) 176 177 ADD_LIBRARY(quacode ${QUACODE_SRCS} ${QUACODE_HEADERS} ${QUACODE_HPP}) 178 TARGET_LINK_LIBRARIES(quacode ${GECODE_LIBRARIES}) 179 SET_TARGET_PROPERTIES(quacode PROPERTIES COMPILE_DEFINITIONS "BUILD_QUACODE_LIB") 180 INSTALL(TARGETS quacode LIBRARY DESTINATION lib ARCHIVE DESTINATION lib/static) 181 SET(QUACODE_LIBRARIES quacode) 182 183 IF(BUILD_EXAMPLES) 184 # Add targets for examples 185 FOREACH (example ${QUACODE_EXAMPLES_SRCS}) 186 GET_FILENAME_COMPONENT(exampleBin ${example} NAME_WE) 187 ADD_EXECUTABLE(${exampleBin} ${example}) 188 TARGET_LINK_LIBRARIES(${exampleBin} ${QUACODE_LIBRARIES} ${GECODE_LIBRARIES} ${CMAKE_THREAD_LIBS_INIT}) 189 INSTALL(TARGETS ${exampleBin} RUNTIME DESTINATION bin) 190 191 # set -static, when STATIC_LINKING is TRUE and set LINK_SEARCH_END_STATIC 192 # to remove the additional -bdynamic from the linker line. 193 IF(UNIX AND STATIC_LINKING) 194 SET(CMAKE_EXE_LINKER_FLAGS "-static") 195 SET_TARGET_PROPERTIES(${exampleBin} PROPERTIES LINK_SEARCH_END_STATIC 1) 196 ENDIF(UNIX AND STATIC_LINKING) 197 ENDFOREACH () 198 ENDIF(BUILD_EXAMPLES) 199 200ENDIF(NOT GECODE_FOUND)