source: common/trunk/bootstrap/packages/CMakeLists.txt @ 7410

Revision 7410, 7.0 KB checked in by wjbohnh, 2 years ago (diff)

Fixed the CMake build when tpl/3po/cobyla is enabled. Addresses a DAKOTA/COLINY
package "registration issue" which led to test FAIL reported by Mike Eldred and
Dena Vigil.

Request review by John Siirola or Brian Adams.

  • Property svn:eol-style set to native
  • Property svn:keywords set to Author Date ID Revision
  • Property svn:mime-type set to text/plain
Line 
1cmake_minimum_required(VERSION 2.6)
2
3project(Acro-Packages)
4
5set(CMAKE_ARCHIVE_OUTPUT_DIRECTORY ${CMAKE_CURRENT_BINARY_DIR}/lib)
6set(CMAKE_LIBRARY_OUTPUT_DIRECTORY ${CMAKE_CURRENT_BINARY_DIR}/lib)
7 
8#flag so subprojects can tell that they're being built by acro
9set(BUILT_BY_ACRO TRUE)
10
11# generate acro_config.h
12function(FindOptionalLibrary library)
13  option(HAVE_${library} "Should Acro use ${library}?" OFF)
14  if(${library}_LIB OR ${library}_LIBS)
15    set(HAVE_${library} ON CACHE BOOL "Should Acro use ${library}?" FORCE)
16  endif()
17  if(HAVE_${library})
18    string(TOLOWER ${library} library_lower)
19    find_library(${library}_LIB ${library_lower})
20    if(${library}_LIB)
21      set(HAVE_${library} TRUE)
22      add_definitions(-DHAVE_${library})
23    endif()
24  endif()
25endfunction()
26
27FindOptionalLibrary(BLAS)
28FindOptionalLibrary(CPLEX)
29
30include(CheckIncludeFiles)
31# appears no acro sources depend on this define any longer
32#CHECK_INCLUDE_FILES("sys/types.h" HAVE_SYS_TYPES_H)
33#if(HAVE_SYS_TYPES_H)
34#  add_definitions(-DHAVE_SYS_TYPES_H)
35#endif()
36# some pico sources (and possibly utilib) MIGHT be using this
37CHECK_INCLUDE_FILES("values.h" HAVE_VALUES_H)
38if(HAVE_VALUES_H)
39  add_definitions(-DHAVE_VALUES_H)
40endif()
41
42
43# replicate TPL defs for now
44if(HAVE_AMPL)
45  add_definitions(-DACRO_USING_AMPL)
46endif()
47
48if(HAVE_3PO)
49  add_definitions(-DACRO_USING_THREEPO)
50endif()
51
52if(HAVE_TINYXML)
53  add_definitions(-DACRO_USING_TINYXML)
54endif()
55
56if(HAVE_APPSPACK)
57  add_definitions(-DACRO_USING_APPSPACK)
58endif()
59
60if(HAVE_GLPK)
61  add_definitions(-DACRO_USING_GLPK)
62endif()
63
64if(HAVE_SOPLEX)
65  add_definitions(-DACRO_USING_SOPLEX)
66endif()
67
68set(packages
69  "${CMAKE_CURRENT_SOURCE_DIR}/colin"
70  "${CMAKE_CURRENT_SOURCE_DIR}/interfaces"
71  "${CMAKE_CURRENT_SOURCE_DIR}/jega"
72  "${CMAKE_CURRENT_SOURCE_DIR}/optpp"
73  "${CMAKE_CURRENT_SOURCE_DIR}/pebbl"
74  "${CMAKE_CURRENT_SOURCE_DIR}/pico"
75  "${CMAKE_CURRENT_SOURCE_DIR}/scolib"
76  "${CMAKE_CURRENT_SOURCE_DIR}/sundry"
77  "${CMAKE_CURRENT_SOURCE_DIR}/utilib")
78
79foreach(package ${packages})
80  AcroCheckDirExists("${package}")
81endforeach()
82
83option(HAVE_BOOST "Should Acro use BOOST?" ON)
84option(ACRO_HAVE_MPI "Should Acro use MPI?" OFF)
85option(VALIDATING "Turn on code validation tests?" OFF)
86
87configure_file(
88  ${Acro_SOURCE_DIR}/config/acro_config.h.cmake.in
89  ${Acro-Packages_BINARY_DIR}/acro_config.h
90)
91include_directories(${Acro-Packages_BINARY_DIR})
92install(FILES ${Acro-Packages_BINARY_DIR}/acro_config.h DESTINATION include)
93
94if(HAVE_BOOST)
95  set(Boost_USE_MULTITHREADED OFF)
96  find_package(Boost COMPONENTS signals)
97  include_directories(${Boost_INCLUDE_DIRS})
98  add_definitions(-DHAVE_BOOST)
99endif()
100
101option(HAVE_MOMHLIB "Build with MOMHLib enabled?" OFF)
102if(HAVE_MOMHLIB)
103  find_path(MOMHLIB_DIR libmomh-config.h DOC "Path to directory containing libmomh-config.h")
104  find_path(SIGCPP_DIR sigc++/sigc++.h DOC "Path to directory containing sigc++.h")
105  find_path(SIGCPPCONFIG_DIR sigc++config.h DOC "Path to directory containing sigc++config.h")
106  if(NOT MOMHLIB_DIR)
107    message(SEND_ERROR "HAVE_MOMHLIB is ON, but MOMHLIB_DIR is not found.  Please set MOMHLIB_DIR to the location of libmomh-config.h")
108  endif()
109  if(NOT SIGCPP_DIR)
110    message(SEND_ERROR "HAVE_MOMHLIB is ON, but SIGCPP_DIR is not found.  Please set SIGCPP_DIR to the location of sigc++/sigc++.h")
111  endif()
112  if(NOT SIGCPPCONFIG_DIR)
113    message(SEND_ERROR "HAVE_MOMHLIB is ON, but SIGCPPCONFIG_DIR is not found.  Please set SIGCPPCONFIG_DIR to the location of sigc++config.h")
114  endif()
115  set(MOMHLIB_INCLUDE_DIRS ${MOMHLIB_DIR} ${SIGCPP_DIR} ${SIGCPPCONFIG_DIR})
116  add_definitions(-DACRO_USING_MOMHLIB)
117endif()
118
119if(ACRO_HAVE_MPI)
120  find_package(MPI)
121  add_definitions(-DHAVE_MPI)
122endif()
123
124
125if(HAVE_TINYXML)
126  find_path(TINYXML_DIR tinyxml.h DOC "Path to directory containing tinyxml.h")
127  if(NOT TINYXML_DIR)
128    message(SEND_ERROR "HAVE_TINYXML is ON, but TINYXML_DIR is not found.  Please set TINYXML_DIR to the location of tinyxml/tinyxml.h")
129  endif()
130endif()
131
132# In Acro, presence of a local tecuhos/optpp means Acro needs it,
133# but it might be provided externally by the user, e.g., in DAKOTA.
134# Take care in case HAVE_DAKOTA set by a parent instead of locally.
135if(HAVE_OPTPP AND EXISTS ${CMAKE_CURRENT_SOURCE_DIR}/optpp)
136  add_definitions(-DACRO_USING_OPTPP)
137  add_subdirectory(optpp)
138  # manage Acro dependence separately from DAKOTA's for now
139  set(ACRO_HAVE_OPTPP ON CACHE BOOL "Acro building with OPT++")
140endif()
141
142if(HAVE_SUNDRY)
143  add_subdirectory(sundry)
144endif()
145
146if(HAVE_UTILIB)
147  add_subdirectory(utilib)
148endif()
149
150if(HAVE_AMPL AND NOT AMPL_INCLUDE_DIRS)
151  set(AMPL_INCLUDE_DIRS ${amplsolver_SOURCE_DIR} ${amplsolver_BINARY_DIR})
152endif()
153
154if(HAVE_COLIN)
155  if(NOT HAVE_UTILIB)
156    message(SEND_ERROR " HAVE_COLIN requires HAVE_UTILIB to be turned ON")
157  endif()
158  if(NOT HAVE_BOOST)
159    message(SEND_ERROR " HAVE_COLIN requires HAVE_BOOST to be turned ON")
160  endif()
161  if (NOT HAVE_TINYXML)
162    message(SEND_ERROR " HAVE_COLIN requires HAVE_TINYXML to be turned ON")
163  endif()
164  add_subdirectory(colin)
165endif()
166
167if(HAVE_PEBBL)
168  if(NOT HAVE_UTILIB)
169    message(ERROR " HAVE_PEBBL requires HAVE_UTILIB to be turned ON")
170  endif()
171  include_directories(${CMAKE_CURRENT_SOURCE_DIR}/utilib/src
172                      ${CMAKE_CURRENT_BINARY_DIR}/utilib)
173  add_definitions(-DACRO_USING_PEBBL)
174  add_subdirectory(pebbl)
175endif()
176
177if(HAVE_SCOLIB)
178  if(NOT HAVE_COLIN)
179      message(ERROR " HAVE_SCOLIB requires HAVE_COLIN to be turned ON")
180  endif()
181  include_directories(${CMAKE_CURRENT_SOURCE_DIR}/pebbl/src
182                      ${CMAKE_CURRENT_SOURCE_DIR}/pebbl/src/bb
183                      ${CMAKE_CURRENT_SOURCE_DIR}/pebbl/src/example
184                      ${CMAKE_CURRENT_SOURCE_DIR}/pebbl/src/misc
185                      ${CMAKE_CURRENT_BINARY_DIR}/pebbl)
186  include_directories(${CMAKE_CURRENT_SOURCE_DIR}/utilib/src
187                      ${CMAKE_CURRENT_BINARY_DIR}/utilib)
188  include_directories(${CMAKE_CURRENT_SOURCE_DIR}/colin/src
189                      ${CMAKE_CURRENT_BINARY_DIR}/colin)
190  add_definitions(-DACRO_USING_SCOLIB)
191  add_subdirectory(scolib)
192endif()
193
194if(HAVE_INTERFACES)
195  # Interfaces can USE OPT++ and SCOLib, but they are not required
196  if(NOT HAVE_COLIN)
197    message(SEND_ERROR " HAVE_INTERFACES requires HAVE_COLIN to be turned ON")
198  endif()
199  include_directories(
200    ${CMAKE_CURRENT_SOURCE_DIR}/scolib/src
201    ${CMAKE_CURRENT_SOURCE_DIR}/utilib/src
202    ${CMAKE_CURRENT_BINARY_DIR}/utilib
203  )
204  if (ACRO_HAVE_OPTPP)
205    include_directories(
206      ${CMAKE_CURRENT_SOURCE_DIR}/optpp/include
207      ${CMAKE_CURRENT_BINARY_DIR}/optpp
208      )     
209  endif()
210  if(HAVE_3PO)
211    add_definitions(-DACRO_USING_THREEPO)
212
213    find_path(COBYLA_DIR cobyla.h DOC "Path to directory containing cobyla.h")
214    if(COBYLA_DIR)
215      add_definitions(-DACRO_USING_COBYLA)
216    else()
217      message(SEND_ERROR "HAVE_3PO is ON, but COBYLA_DIR is not found.  Please set COBYLA_DIR to the location of cobyla2c/cobyla.h")
218    endif()
219
220  endif()
221  add_subdirectory(interfaces)
222endif()
223
224if(HAVE_PICO)
225  if(NOT HAVE_PEBBL)
226    message(SEND_ERROR " HAVE_PICO requires HAVE_PEBBL to be turned ON")
227  endif()
228  add_subdirectory(pico)
229endif()
Note: See TracBrowser for help on using the repository browser.