Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
53 commits
Select commit Hold shift + click to select a range
bbce4a8
Added CMake options from autoconf and find-package Find*.cmake files
Nov 11, 2021
7c6d053
Added checks and includes for system libs, functions and headers
Nov 11, 2021
04d7e16
gitignore CLion IDE files
Nov 11, 2021
67bcbfc
fixed missing CMake includes
Nov 11, 2021
ebc2f7e
fixed compile definitions
Nov 11, 2021
8865447
added missing gmp.h
Nov 11, 2021
d2e14a6
Moved `Find*.cmake` to ./cmake, removed `set(CMAKE_MODULE_PATH ".")`
Nov 11, 2021
7f7a608
added `glpsol` executable target plus tests
Nov 11, 2021
6aa1ef2
replaced hardcoded paths with CMake variables
Nov 11, 2021
7afddc0
removed `gmp.h`, added `find_path` to find it on the host system
Nov 11, 2021
0237935
removed `gmp.h`, added `find_path` to find it on the host system
Nov 11, 2021
ce26bb1
fixed copy-paste code errors, added missing `GPSOL` target include di…
Nov 11, 2021
a96f6e5
Merge branch 'Mizux:main' into main
Two4 Nov 11, 2021
bd4887e
revert GPSOL changes in favour of MUCH better upstream GPSOL changes
Nov 11, 2021
f384b7b
added GPSOL smoke tests
Nov 11, 2021
ab69078
switched to dune-common version of `FindGMP.cmake`
Nov 11, 2021
ca65817
added default `OFF` for CMake option `ODBC`
Nov 11, 2021
bbab4a7
removed lingering GPSOL change
Nov 11, 2021
3120d10
clarified TLS comment
Nov 11, 2021
99bfeb6
another GLPSOL change reverted
Nov 11, 2021
0ba82af
Fixed `target_link_libraries` not working on *nix
Nov 11, 2021
baa2fbb
Fixed `target_link_libraries` not working on *nix
Nov 11, 2021
ba81562
removed unneeded math lib check
Nov 11, 2021
93a76fb
Merge remote-tracking branch 'origin/main' into main
Nov 11, 2021
41a7ffd
remove unused CMake vars
Nov 11, 2021
0ea516f
use `find_package(ODBC)` rather than `include(FindODBC)` for more con…
Nov 11, 2021
81d93e0
escape parentheses
Nov 11, 2021
aa62013
fixed misleading comment - DLLs are supported, but default off on Win…
Nov 11, 2021
7d4476f
allow `WITH_GMP` on Windows, but default to `OFF`
Nov 11, 2021
5958194
fixed `gettimeofday` function check
Nov 11, 2021
e78e02b
added libm link for examples (some were failing)
Nov 12, 2021
d76dbf8
moved example directory target enumeration to its own function
Nov 12, 2021
6fd2ccd
changed `add_compile_definitions` to `target_compile_definitions` as …
Nov 12, 2021
04b909c
fixed gpsol smoke tests
Nov 12, 2021
14fa8e6
used new `add_example_folder` function to add all tests/examples and …
Nov 12, 2021
b6d6153
copy library to test output dirs to allow tests to run
Nov 12, 2021
1461d81
CMake will now always try to find libgmp, but will warn and continue …
Nov 12, 2021
24be42f
remove cplex example due to missing external deps
Nov 12, 2021
2cdd7f7
include src folder for examples
Nov 12, 2021
49f3d0a
added missing define for MSVC builds, restructured system checks
Nov 12, 2021
8c27127
missing libgmp now gives dev warning instead of warning
Nov 12, 2021
2d6693b
libgmp check no longer depends on option, moved to `src/CmakeLists.txt`
Nov 12, 2021
a788400
added missing GLPK dependence for tsp examples
Nov 12, 2021
aaf643a
comment out problematic `#include <malloc.h>` (non-standard, deprecated)
Nov 12, 2021
c70e08e
changed dependencies around for tsp libs
Nov 12, 2021
24ef74b
try to fix failing test on XCode
Nov 13, 2021
1403065
add option status messages for configure/build logs
Nov 13, 2021
49ed231
added warning message when compiler not recognised for thread-local s…
Nov 13, 2021
516f69f
moved example data configuration to its own function
Nov 13, 2021
3b0511f
tspsol and tsplib are now project exports, and their dependencies are…
Nov 13, 2021
dd67aef
now using ODBC::ODBC target as dependency
Nov 13, 2021
b366105
fixed copy-paste code mistake
Nov 13, 2021
81b239e
removed copying of glpk lib to example directories (no longer applica…
Nov 15, 2021
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
65 changes: 64 additions & 1 deletion CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -47,7 +47,7 @@ if(UNIX)
set(CMAKE_RUNTIME_OUTPUT_DIRECTORY_${OUTPUTCONFIG} ${CMAKE_BINARY_DIR}/${OutputConfig}/${CMAKE_INSTALL_BINDIR})
endforeach()
else()
# Currently Only support static build for windows
# Default to static build for non-unix
option(BUILD_SHARED_LIBS "Build shared libraries (.dll)." OFF)
set(CMAKE_LIBRARY_OUTPUT_DIRECTORY ${CMAKE_BINARY_DIR}/${CMAKE_INSTALL_BINDIR})
set(CMAKE_ARCHIVE_OUTPUT_DIRECTORY ${CMAKE_BINARY_DIR}/${CMAKE_INSTALL_BINDIR})
Expand All @@ -70,3 +70,66 @@ include(c)
option(BUILD_EXAMPLES "Build examples" ON)
message(STATUS "Build examples: ${BUILD_EXAMPLES}")
add_subdirectory(examples)

option(ODBC "enable MathProg ODBC support" OFF)
message(STATUS "enable MathProg ODBC support: ${ODBC}")
if(ODBC)
find_package(ODBC)
if(ODBC_FOUND)
if(ODBC_CONFIG)
execute_process(COMMAND "${ODBC_CONFIG} --cflags"
RESULT_VARIABLE ODBC_RESULT
OUTPUT_VARIABLE ODBC_OUTPUT
ERROR_VARIABLE ODBC_ERROR)
if(ODBC_OUTPUT AND (NOT ODBC_ERROR))
set(CMAKE_C_FLAGS "${CMAKE_C_FLAGS} ${ODBC_OUTPUT}")
elseif(ODBC_ERROR)
message(FATAL_ERROR "'${ODBC_CONFIG} --cflags' returned ${ODBC_RESULT}: ${ODBC_ERROR}")
else()
message(FATAL_ERROR "'${ODBC_CONFIG} --cflags' produced no output")
endif()
else()
message(FATAL_ERROR "Could not run 'odbc-config --cflags' or 'iodbc-config --cflags'")
endif()
string(REGEX MATCH "/[^/\\]+$/gm" ODBC_LIB_NAME "${ODBC_LIBRARIES}") # regexr.com/698ls strips the preceding path from the actual lib name
if (ODBC_LIB_NAME)
target_compile_definitions(GLPK PUBLIC ODBC_DLNAME=${ODBC_LIB_NAME})
target_link_libraries(GLPK PRIVATE ODBC::ODBC)
else()
message(FATAL_ERROR "Could not determine ODBC/iODBC library name")
endif()
else()
message(FATAL_ERROR "ODBC/iODBC library not found")
endif()
endif()

include(CMakeDependentOption)
cmake_dependent_option(MYSQL "enable MathProg MySQL support" OFF "BUILD_SHARED_LIBS" OFF)
message(STATUS "enable MathProg MySQL support: ${MYSQL}")
if(MYSQL)
find_package(MySQL)
if(MYSQL_FOUND)
target_link_libraries(GLPK GMP_LIBRARIES)
target_include_directories(GLPK MYSQL_INCLUDE_DIRS)
else()
message(FATAL_ERROR "MySQL not found")
endif()
endif()

option(IS_REENTRANT "enable reentrancy support" ON)
message(STATUS "enable reentrancy support: ${IS_REENTRANT}")
if(IS_REENTRANT)
if (
(CMAKE_C_COMPILER_ID MATCHES "Clang") OR # matches AppleClang and Clang
(CMAKE_C_COMPILER_ID STREQUAL "GNU") OR
(CMAKE_C_COMPILER_ID STREQUAL "Intel")
)
set(TLS "__thread")
elseif (CMAKE_C_COMPILER_ID STREQUAL "MSVC")
set(TLS "__declspec(thread)")
else()
message(WARNING "compiler-specific spec for thread local storage not found; if your build breaks, set 'IS_REENTRANT' option to 'OFF'")
set(TLS "_Thread_local") # default to C11 standard, may break some builds if thread local storage isn't supported
endif()
target_compile_definitions(GLPK PUBLIC TLS=${TLS})
endif()
180 changes: 180 additions & 0 deletions cmake/FindGMP.cmake
Original file line number Diff line number Diff line change
@@ -0,0 +1,180 @@
#### LICENSE ####
# This file is copied from the Dune project (http://dune-project.org/), specifically the dune-project/dune-common git
# repo (https://github.com/dune-project/dune-common), and is thus licensed under a modified GPLv2 license. A copy of
# that license can be found in this directory as `dune-common-gplv2.md`.
#
# The original file can be found at https://github.com/dune-project/dune-common/blob/v2.8.0/cmake/modules/FindGMP.cmake
#
# Copyright holders:
# ==================
#
# 2015--2017 Marco Agnese
# 2015 Martin Alkämper
# 2003--2019 Peter Bastian
# 2004--2020 Markus Blatt
# 2013 Andreas Buhr
# 2020--2021 Samuel Burbulla
# 2011--2020 Ansgar Burchardt
# 2004--2005 Adrian Burri
# 2014 Benjamin Bykowski (may appear in the logs as "Convex Function")
# 2014 Marco Cecchetti
# 2018 Matthew Collins
# 2006--2021 Andreas Dedner
# 2019--2021 Nils-Arne Dreier
# 2003 Marc Droske
# 2003--2021 Christian Engwer
# 2004--2020 Jorrit Fahlke
# 2016 Thomas Fetzer
# 2008--2017 Bernd Flemisch
# 2013--2014 Christoph Gersbacher
# 2017--2020 Janick Gerstenberger
# 2015 Stefan Girke
# 2005--2021 Carsten Gräser
# 2015--2017 Felix Gruber
# 2010--2021 Christoph Grüninger
# 2006 Bernhard Haasdonk
# 2015--2018 Claus-Justus Heine
# 2015--2020 René Heß
# 2017--2019 Stephan Hilb
# 2017--2021 Lasse Hinrichsen
# 2012--2013 Olaf Ippisch
# 2020 Patrick Jaap
# 2020 Liam Keegan
# 2013--2021 Dominic Kempf
# 2009 Leonard Kern
# 2017--2018 Daniel Kienle
# 2013 Torbjörn Klatt
# 2003--2021 Robert Klöfkorn
# 2017--2021 Timo Koch
# 2005--2007 Sreejith Pulloor Kuttanikkad
# 2012--2016 Arne Morten Kvarving
# 2010--2014 Andreas Lauser
# 2016--2019 Tobias Leibner
# 2015 Lars Lubkoll
# 2012--2017 Tobias Malkmus
# 2007--2011 Sven Marnach
# 2010--2017 Rene Milk
# 2019--2020 Felix Müller
# 2011--2019 Steffen Müthing
# 2018 Lisa Julia Nebel
# 2003--2006 Thimo Neubauer
# 2011 Rebecca Neumann
# 2008--2018 Martin Nolte
# 2014 Andreas Nüßing
# 2004--2005 Mario Ohlberger
# 2019--2020 Santiago Ospina De Los Rios
# 2014 Steffen Persvold
# 2008--2017 Elias Pipping
# 2021 Joscha Podlesny
# 2011 Dan Popovic
# 2017--2021 Simon Praetorius
# 2009 Atgeirr Rasmussen
# 2017--2020 Lukas Renelt
# 2006--2014 Uli Sack
# 2003--2020 Oliver Sander
# 2006 Klaus Schneider
# 2004 Roland Schulz
# 2015 Nicolas Schwenck
# 2016 Linus Seelinger
# 2009--2014 Bård Skaflestad
# 2019 Henrik Stolzmann
# 2012 Matthias Wohlmuth
# 2011--2016 Jonathan Youett

#[=======================================================================[.rst:
FindGMP
-------

Find the GNU MULTI-Precision Bignum (GMP) library
and the corresponding C++ bindings GMPxx.

This module searches for both libraries and only considers the package
found if both can be located. It then defines separate targets for the C
and the C++ library.

Imported Targets
^^^^^^^^^^^^^^^^

This module provides the following imported targets, if found:

``GMP::gmp``
Library target of the C library.
``GMP::gmpxx``
Library target of the C++ library, which also links to the C library.

Result Variables
^^^^^^^^^^^^^^^^

This will define the following variables:

``GMP_FOUND``
True if the GMP library, the GMPxx headers and
the GMPxx library were found.

Cache Variables
^^^^^^^^^^^^^^^

You may set the following variables to modify the behaviour of
this module:

``GMP_INCLUDE_DIR``
The directory containing ``gmp.h``.
``GMP_LIB``
The path to the gmp library.
``GMPXX_INCLUDE_DIR``
The directory containing ``gmpxx.h``.
``GMPXX_LIB``
The path to the gmpxx library.

#]=======================================================================]

# Add a feature summary for this package
include(FeatureSummary)
set_package_properties(GMP PROPERTIES
DESCRIPTION "GNU multi-precision library"
URL "https://gmplib.org"
)

# Try finding the package with pkg-config
find_package(PkgConfig QUIET)
pkg_check_modules(PKG QUIET gmp gmpxx)

# Try to locate the libraries and their headers, using pkg-config hints
find_path(GMP_INCLUDE_DIR gmp.h HINTS ${PKG_gmp_INCLUDEDIR})
find_library(GMP_LIB gmp HINTS ${PKG_gmp_LIBDIR})

find_path(GMPXX_INCLUDE_DIR gmpxx.h HINTS ${PKG_gmpxx_INCLUDEDIR})
find_library(GMPXX_LIB gmpxx HINTS ${PKG_gmpxx_LIBDIR})

# Remove these variables from cache inspector
mark_as_advanced(GMP_INCLUDE_DIR GMP_LIB GMPXX_INCLUDE_DIR GMPXX_LIB)

# Report if package was found
include(FindPackageHandleStandardArgs)
find_package_handle_standard_args(GMP
DEFAULT_MSG
GMPXX_LIB GMPXX_INCLUDE_DIR GMP_INCLUDE_DIR GMP_LIB
)

# Set targets
if(GMP_FOUND)
# C library
if(NOT TARGET GMP::gmp)
add_library(GMP::gmp UNKNOWN IMPORTED)
set_target_properties(GMP::gmp PROPERTIES
IMPORTED_LOCATION ${GMP_LIB}
INTERFACE_INCLUDE_DIRECTORIES ${GMP_INCLUDE_DIR}
)
endif()

# C++ library, which requires a link to the C library
if(NOT TARGET GMP::gmpxx)
add_library(GMP::gmpxx UNKNOWN IMPORTED)
set_target_properties(GMP::gmpxx PROPERTIES
IMPORTED_LOCATION ${GMPXX_LIB}
INTERFACE_INCLUDE_DIRECTORIES ${GMPXX_INCLUDE_DIR}
INTERFACE_LINK_LIBRARIES GMP::gmp
)
endif()

endif()
75 changes: 75 additions & 0 deletions cmake/FindMySQL.cmake
Original file line number Diff line number Diff line change
@@ -0,0 +1,75 @@
# https://gist.github.com/RenatoUtsch/1623340
# - Try to find MySQL.
# Once done this will define:
# MYSQL_FOUND - If false, do not try to use MySQL.
# MYSQL_INCLUDE_DIRS - Where to find mysql.h, etc.
# MYSQL_LIBRARIES - The libraries to link against.
# MYSQL_VERSION_STRING - Version in a string of MySQL.
#
# Created by RenatoUtsch based on eAthena implementation.
#
# Please note that this module only supports Windows and Linux officially, but
# should work on all UNIX-like operational systems too.
#
#=============================================================================
# Copyright 2012 RenatoUtsch
#
# Distributed under the OSI-approved BSD License (the "License");
# see accompanying file Copyright.txt for details.
#
# This software is distributed WITHOUT ANY WARRANTY; without even the
# implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.
# See the License for more information.
#=============================================================================
# (To distribute this file outside of CMake, substitute the full
# License text for the above reference.)
if( WIN32 )
find_path( MYSQL_INCLUDE_DIR
NAMES "mysql.h"
PATHS "$ENV{PROGRAMFILES}/MySQL/*/include"
"$ENV{PROGRAMFILES\(x86\)}/MySQL/*/include"
"$ENV{SYSTEMDRIVE}/MySQL/*/include" )

find_library( MYSQL_LIBRARY
NAMES "mysqlclient" "mysqlclient_r"
PATHS "$ENV{PROGRAMFILES}/MySQL/*/lib"
"$ENV{PROGRAMFILES\(x86\)}/MySQL/*/lib"
"$ENV{SYSTEMDRIVE}/MySQL/*/lib" )
else()
find_path( MYSQL_INCLUDE_DIR
NAMES "mysql.h"
PATHS "/usr/include/mysql"
"/usr/local/include/mysql"
"/usr/mysql/include/mysql" )

find_library( MYSQL_LIBRARY
NAMES "mysqlclient" "mysqlclient_r"
PATHS "/lib/mysql"
"/lib64/mysql"
"/usr/lib/mysql"
"/usr/lib64/mysql"
"/usr/local/lib/mysql"
"/usr/local/lib64/mysql"
"/usr/mysql/lib/mysql"
"/usr/mysql/lib64/mysql" )
endif()

if( MYSQL_INCLUDE_DIR AND EXISTS "${MYSQL_INCLUDE_DIRS}/mysql_version.h" )
file( STRINGS "${MYSQL_INCLUDE_DIRS}/mysql_version.h"
MYSQL_VERSION_H REGEX "^#define[ \t]+MYSQL_SERVER_VERSION[ \t]+\"[^\"]+\".*$" )
string( REGEX REPLACE
"^.*MYSQL_SERVER_VERSION[ \t]+\"([^\"]+)\".*$" "\\1" MYSQL_VERSION_STRING
"${MYSQL_VERSION_H}" )
endif()

# handle the QUIETLY and REQUIRED arguments and set MYSQL_FOUND to TRUE if
# all listed variables are TRUE
include( FindPackageHandleStandardArgs )
find_package_handle_standard_args( MYSQL DEFAULT_MSG
REQUIRED_VARS MYSQL_LIBRARY MYSQL_INCLUDE_DIR
VERSION_VAR MYSQL_VERSION_STRING )

set( MYSQL_INCLUDE_DIRS ${MYSQL_INCLUDE_DIR} )
set( MYSQL_LIBRARIES ${MYSQL_LIBRARY} )

mark_as_advanced( MYSQL_INCLUDE_DIR MYSQL_LIBRARY )
3 changes: 2 additions & 1 deletion cmake/c.cmake
Original file line number Diff line number Diff line change
Expand Up @@ -83,7 +83,8 @@ function(add_c_example FILE_NAME)
target_include_directories(${EXAMPLE_NAME} PUBLIC ${CMAKE_CURRENT_SOURCE_DIR})
target_compile_features(${EXAMPLE_NAME} PRIVATE c_std_11)
target_link_libraries(${EXAMPLE_NAME} PRIVATE
${PROJECT_NAMESPACE}::GLPK)
${PROJECT_NAMESPACE}::GLPK
$<$<NOT:$<C_COMPILER_ID:MSVC>>:m>)

include(GNUInstallDirs)
install(TARGETS ${EXAMPLE_NAME})
Expand Down
Loading