Skip to content

Commit

Permalink
* Fix cmake process for gams (#86)
Browse files Browse the repository at this point in the history
Co-authored-by: Leo Georgescu <georgl97@icloud.com>
  • Loading branch information
jredmondson and leogeo13 authored Dec 16, 2023
1 parent c156c6a commit 416e6d7
Show file tree
Hide file tree
Showing 3 changed files with 27 additions and 12 deletions.
16 changes: 12 additions & 4 deletions CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,14 @@ include(gams_macros)
# Define the GAMS project and version
project(GAMS VERSION "${GAMS_VERSION}")

# set(GAMS_ROOT ${PROJECT_SOURCE_DIR})

find_package(madara ${MIN_MADARA_VERSION} REQUIRED)
find_package(Boost REQUIRED COMPONENTS system)
find_package(Eigen3 REQUIRED)

include_directories(SYSTEM ${EIGEN3_INCLUDE_DIRS})

# Provide a lowercase version of project
string(TOLOWER ${PROJECT_NAME} PROJECT_NAME_LOWER)
string(TOUPPER ${PROJECT_NAME} PROJECT_NAME_UPPER)
Expand Down Expand Up @@ -66,7 +74,7 @@ set(CMAKE_CXX_STANDARD_REQUIRED True)
# disable certain warnings that will occur in VS
if(MSVC)

set(GAMS_INC_INSTALL_DIR "include/gams")
set(GAMS_INC_INSTALL_DIR "include")
set(GAMS_RUNTIME_INSTALL_DIR "bin")
set(GAMS_LIBRARY_INSTALL_DIR "bin")
set(GAMS_ARCHIVE_INSTALL_DIR "lib")
Expand All @@ -87,7 +95,7 @@ if(MSVC)
elseif(UNIX)
include(GNUInstallDirs)

set(GAMS_INC_INSTALL_DIR "${CMAKE_INSTALL_INCLUDEDIR}/madara")
set(GAMS_INC_INSTALL_DIR "${CMAKE_INSTALL_INCLUDEDIR}/gams")
set(GAMS_RUNTIME_INSTALL_DIR "${CMAKE_INSTALL_BINDIR}")
set(GAMS_LIBRARY_INSTALL_DIR "${CMAKE_INSTALL_LIBDIR}")
set(GAMS_ARCHIVE_INSTALL_DIR "${CMAKE_INSTALL_LIBDIR}")
Expand All @@ -106,7 +114,7 @@ include(cmake/configuration.cmake)

# Build the main library
add_subdirectory(src)
add_subdirectory(src/gams/programs)
#add_subdirectory(src/gams/programs)

# Build tests
if(gams_TESTS)
Expand All @@ -120,7 +128,7 @@ endif()

set(PKG_NAME ${PROJECT_NAME_UPPER})
set(PKG_LIBRARIES gams)
set(PKG_DEPENDS madara Boost::boost)
set(PKG_DEPENDS madara Boost::boost Boost::system)

# install readme and license
install(FILES "${CMAKE_CURRENT_SOURCE_DIR}/LICENSE.txt" "${CMAKE_CURRENT_SOURCE_DIR}/VERSION.txt" "${CMAKE_CURRENT_SOURCE_DIR}/README.md" DESTINATION ${GAMS_ADDITIONAL_FILES_INSTALL_DIR})
Expand Down
13 changes: 10 additions & 3 deletions bin/generate_version_include.pl
Original file line number Diff line number Diff line change
Expand Up @@ -9,19 +9,26 @@
# version number for inclusion with C++.
###################################################

my $txt_fname = $ENV{'GAMS_ROOT'} . "/VERSION.txt";
my $h_fname = $ENV{'GAMS_ROOT'} . "/src/gams/utility/Version.h";
use File::Basename;

my $path = dirname(__FILE__);
$path .= "/..";

my $txt_fname = "$path/VERSION.txt";
my $h_fname = "$path/src/gams/utility/Version.h";
my $txt_mdate = (stat $txt_fname)[9];
my $h_mdate = (stat $h_fname)[9];

print "$ENV{'GAMS_ROOT'}\n";

if ($txt_mdate < $h_mdate) {
exit 0;
}

print "Generating: reading from $txt_fname\n";

open VERSION_FILE, "<", $txt_fname or
die "Unable to open ../VERSION.txt for reading.";
die "Unable to open $txt_fname for reading.";
$version = <VERSION_FILE>;
close VERSION_FILE;

Expand Down
10 changes: 5 additions & 5 deletions src/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -82,14 +82,14 @@ if(MSVC)
set(Boost_USE_RELEASE_LIBS ON) # only find release libs
set(Boost_USE_MULTITHREADED ON)
set(Boost_USE_STATIC_RUNTIME ON)
find_package(Boost 1.60.0 REQUIRED)
#find_package(Boost 1.60.0 REQUIRED)
else()
set(Boost_USE_STATIC_LIBS OFF) # only find static libs
set(Boost_USE_DEBUG_LIBS OFF) # ignore debug libs and
set(Boost_USE_RELEASE_LIBS ON) # only find release libs
set(Boost_USE_MULTITHREADED ON)
set(Boost_USE_STATIC_RUNTIME OFF)
find_package(Boost 1.60.0 REQUIRED COMPONENTS system)
#find_package(Boost 1.60.0 REQUIRED COMPONENTS system)
endif()

# try to match up any GAMS features requested
Expand All @@ -100,7 +100,7 @@ set(madara_THREADLOCAL ${gams_THREADLOCAL})
set(madara_THREADLOCAL ${gams_THREADLOCAL})

# We need this directory, and users of our library will need it too
find_package(madara 3.3.0 REQUIRED)
#find_package(madara 3.3.0 REQUIRED)

add_custom_command(
OUTPUT ${header_path}/Version.h
Expand All @@ -122,8 +122,8 @@ if(madara_FOUND)

add_dependencies(gams gams_lib_version)

target_include_directories(gams PUBLIC "$ENV{EIGEN_ROOT}")
target_include_directories(gams PUBLIC "$ENV{OSC_ROOT}")
# target_include_directories(gams PUBLIC "$ENV{EIGEN_ROOT}")
# target_include_directories(gams PUBLIC "$ENV{OSC_ROOT}")

set_target_properties(gams PROPERTIES
DEBUG_POSTFIX d)
Expand Down

0 comments on commit 416e6d7

Please # to comment.