-
Notifications
You must be signed in to change notification settings - Fork 64
Add support for EGADS geometry system #330
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
base: develop
Are you sure you want to change the base?
Changes from 89 commits
0232dae
9ffeda7
4678b2d
dd0c9bd
a71b5c3
4698365
494b48c
56de2bd
4d11165
749572f
542eb7f
13c02dc
25ffd58
79a1869
432bea2
f7f35a2
e56f39d
83bab38
c7f8a65
c6cdfc6
4619442
e77a4ef
dbe89db
f474a5b
6e64cda
dc51601
761f5e5
67b60e9
dc71643
8964abe
640d67b
faf8e46
24dab6d
2576981
7437a90
2f07637
dd95ea8
c733e03
eae7fd6
572326e
5e2ef43
383e168
843e549
23de3fc
54d6a06
114273a
a55157a
420a015
7bbb112
7571748
a4e7219
edef983
b63e7e5
cb96614
e317b7e
4664d05
f5b9220
38f65e1
7c43f81
38b539f
cf181ef
c51a0fa
e14c8fe
bdaf4ca
7d5d26e
f3c0892
1832ccc
46f75a8
9a47057
a7e41e3
ad8ab1f
bf4420b
31a02f5
2e505f6
6bfd4c6
a4a41ef
2e1012d
0f8ea73
3ae5571
3fa7bc7
64e1dec
9aff5b6
b6f2b42
4f58438
f145720
f98fe6d
83e59a5
407ead5
afb21d5
910b12a
3f13376
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,33 @@ | ||
# - Try to find EGADS | ||
# Once done this will define | ||
# EGADS_FOUND - System has EGADS | ||
# EGADS_INCLUDE_DIRS - The EGADS include directories | ||
# EGADS_LIBRARIES - The libraries needed to use EGADS/EGADSlite | ||
# EGADSLITE_LIBRARIES - The libraries needed to use EGADSlite | ||
# EGADS_DEFINITIONS - Compiler switches required for using EGADS | ||
|
||
find_path(EGADS_INCLUDE_DIR egads.h PATHS "${EGADS_DIR}/include") | ||
set(EGADS_INCLUDE_DIRS ${EGADS_INCLUDE_DIR}) | ||
|
||
if(${PUMI_USE_EGADSLITE}) | ||
find_library(EGADS_LIBRARY | ||
NAMES egadslite libegadslite.so libegadslite.dylib | ||
PATHS "${EGADS_DIR}/lib") | ||
else() | ||
find_library(EGADS_LIBRARY | ||
NAMES egads libegads.so libegads.dylib | ||
PATHS "${EGADS_DIR}/lib") | ||
endif() | ||
|
||
set(EGADS_LIBRARIES ${EGADS_LIBRARY}) | ||
|
||
include(FindPackageHandleStandardArgs) | ||
# handle the QUIETLY and REQUIRED arguments and set EGADS_FOUND to TRUE | ||
# if all listed variables are TRUE | ||
find_package_handle_standard_args( | ||
EGADS | ||
DEFAULT_MSG | ||
EGADS_INCLUDE_DIR EGADS_LIBRARY | ||
) | ||
|
||
mark_as_advanced(EGADS_INCLUDE_DIR EGADS_LIBRARY) | ||
tuckerbabcock marked this conversation as resolved.
Show resolved
Hide resolved
|
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,256 @@ | ||
#[=======================================================================[.rst: | ||
FindESP | ||
--------- | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. @tuckerbabcock is this something you wrote? The style of the commenting looks different which indicates it might come from elsewhere. If so, we need to include the source/licensing information. There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. @jacobmerson you're right, I should have put some attribution in this file. I "wrote" it, by looking at CMake's built in "FindBoost.cmake" file (https://github.com/Kitware/CMake/blob/master/Modules/FindBoost.cmake) and used that as a template |
||
|
||
Find ESP include dirs and libraries | ||
|
||
Use this module by invoking :command:`find_package` with the form: | ||
|
||
.. code-block:: cmake | ||
|
||
find_package(ESP | ||
[version] [EXACT] # Minimum or EXACT version e.g. 1.19.0 | ||
[REQUIRED] # Fail with error if ESP is not found | ||
[COMPONENTS <libs>...] # ESP libraries by their canonical name | ||
# e.g. "egads" for "libegads" | ||
[OPTIONAL_COMPONENTS <libs>...] | ||
# Optional ESP libraries by their canonical name | ||
) # e.g. "egads" for "libegads" | ||
|
||
This module finds headers and requested component libraries from ESP | ||
|
||
Result Variables | ||
^^^^^^^^^^^^^^^^ | ||
|
||
This module defines the following variables: | ||
|
||
``ESP_FOUND`` | ||
True if headers and requested libraries were found. | ||
|
||
``ESP_INCLUDE_DIRS`` | ||
ESP include directories. | ||
|
||
``ESP_LIBRARY_DIRS`` | ||
Link directories for ESP libraries. | ||
|
||
``ESP_LIBRARIES`` | ||
ESP component libraries to be linked. | ||
|
||
``ESP_<COMPONENT>_FOUND`` | ||
True if component ``<COMPONENT>`` was found. | ||
|
||
``ESP_<COMPONENT>_LIBRARY`` | ||
Libraries to link for component ``<COMPONENT>`` (may include | ||
:command:`target_link_libraries` debug/optimized keywords). | ||
|
||
Cache variables | ||
^^^^^^^^^^^^^^^ | ||
|
||
Search results are saved persistently in CMake cache entries: | ||
|
||
``ESP_INCLUDE_DIR`` | ||
Directory containing ESP headers. | ||
|
||
``ESP_LIBRARY_DIR`` | ||
Directory containing ESP libraries. | ||
|
||
Hints | ||
^^^^^ | ||
|
||
This module reads hints about search locations from variables: | ||
|
||
``ESP_ROOT``, ``ESPROOT`` | ||
Preferred installation prefix. | ||
|
||
``ESP_INCLUDEDIR`` | ||
Preferred include directory e.g. ``<prefix>/include``. | ||
|
||
``ESP_LIBRARYDIR`` | ||
Preferred library directory e.g. ``<prefix>/lib``. | ||
|
||
``ESP_NO_SYSTEM_PATHS`` | ||
Set to ``ON`` to disable searching in locations not | ||
specified by these hint variables. Default is ``OFF``. | ||
|
||
``ESP_ADDITIONAL_VERSIONS`` | ||
List of ESP versions not known to this module. | ||
(ESP install locations may contain the version). | ||
|
||
Users may set these hints or results as ``CACHE`` entries. Projects | ||
should not read these entries directly but instead use the above | ||
result variables. Note that some hint names start in upper-case | ||
``ESP``. One may specify these as environment variables if they are | ||
not specified as CMake variables or cache entries. | ||
|
||
This module first searches for the ESP header files using the above | ||
hint variables (excluding ``ESP_LIBRARYDIR``) and saves the result in | ||
``ESP_INCLUDE_DIR``. Then it searches for requested component libraries | ||
using the above hints (excluding ``ESP_INCLUDEDIR``), "lib" directories | ||
near ``ESP_INCLUDE_DIR``, and the library name configuration settings below. | ||
It saves the library directories in ``ESP_LIBRARY_DIR`` and individual library | ||
locations in ``ESP_<COMPONENT>_LIBRARY``. | ||
When one changes settings used by previous searches in the same build | ||
tree (excluding environment variables) this module discards previous | ||
search results affected by the changes and searches again. | ||
|
||
Imported Targets | ||
^^^^^^^^^^^^^^^^ | ||
|
||
This module defines the following :prop_tgt:`IMPORTED` targets: | ||
|
||
``ESP::ESP`` | ||
Interface target for all components linking against all components. | ||
|
||
``ESP::<component>`` | ||
Target for specific component dependency (shared or static library). | ||
|
||
It is important to note that the imported targets behave differently | ||
than variables created by this module: multiple calls to | ||
:command:`find_package(ESP)` in the same directory or sub-directories with | ||
different options (e.g. static or shared) will not override the | ||
values of the targets created by the first call. | ||
|
||
Examples | ||
^^^^^^^^ | ||
|
||
Find ESP libraries and use imported targets: | ||
|
||
.. code-block:: cmake | ||
|
||
find_package(ESP REQUIRED COMPONENTS | ||
egads ocsm) | ||
add_executable(foo foo.cc) | ||
target_link_libraries(foo ESP::egads ESP::aimUtil) | ||
|
||
#]=======================================================================] | ||
|
||
include(GNUInstallDirs) | ||
|
||
set(quiet "") | ||
if(ESP_FIND_QUIETLY) | ||
set(quiet QUIET) | ||
endif() | ||
|
||
# ------------------------------------------------------------------------ | ||
# Find ESP include dir | ||
# ------------------------------------------------------------------------ | ||
if(NOT ESP_INCLUDE_DIR) | ||
|
||
set(_ESP_INCLUDE_SEARCH_DIRS "") | ||
if(ESP_INCLUDEDIR) | ||
list(APPEND _ESP_INCLUDE_SEARCH_DIRS ${ESP_INCLUDEDIR}) | ||
endif() | ||
|
||
if(DEFINED ENV{ESP_ROOT}) | ||
list(APPEND _ESP_INCLUDE_SEARCH_DIRS $ENV{ESP_ROOT}/include $ENV{ESP_ROOT}) | ||
endif() | ||
|
||
if(DEFINED ENV{ESPROOT}) | ||
list(APPEND _ESP_INCLUDE_SEARCH_DIRS $ENV{ESPROOT}/include $ENV{ESPROOT}) | ||
endif() | ||
|
||
find_path(ESP_INCLUDE_DIR NAMES egads.h HINTS ${_ESP_INCLUDE_SEARCH_DIRS}) | ||
endif() | ||
|
||
message(STATUS "ESP include dir: ${ESP_INCLUDE_DIR}") | ||
|
||
# ------------------------------------------------------------------------ | ||
# Extract version information from egadsTypes.h | ||
# ------------------------------------------------------------------------ | ||
if(ESP_INCLUDE_DIR) | ||
|
||
# Extract ESP_VERSION_MAJOR AND ESP_VERISON_MINOR from egadsTypes.h | ||
set(ESP_VERSION_MAJOR 0) | ||
set(ESP_VERSION_MINOR 0) | ||
file(STRINGS "${ESP_INCLUDE_DIR}/egadsTypes.h" _ESP_VERSION_CONTENTS REGEX "#define EGADSMAJOR ") | ||
if("${_ESP_VERSION_CONTENTS}" MATCHES "#define EGADSMAJOR[ \t\r\n]+([0-9]+)") | ||
set(ESP_VERSION_MAJOR "${CMAKE_MATCH_1}") | ||
endif() | ||
unset(_ESP_VERSION_HEADER_CONTENTS) | ||
|
||
file(STRINGS "${ESP_INCLUDE_DIR}/egadsTypes.h" _ESP_VERSION_CONTENTS REGEX "#define EGADSMINOR ") | ||
if("${_ESP_VERSION_CONTENTS}" MATCHES "#define EGADSMINOR[ \t\r\n]+([0-9]+)") | ||
set(ESP_VERSION_MINOR "${CMAKE_MATCH_1}") | ||
endif() | ||
unset(_ESP_VERSION_HEADER_CONTENTS) | ||
|
||
# ESP versioning does not include a patch number so we set it to zero | ||
SET(ESP_VERSION_PATCH 0) | ||
|
||
# Define alias variables for backwards compat. | ||
set(ESP_MAJOR_VERSION ${ESP_VERSION_MAJOR}) | ||
set(ESP_MINOR_VERSION ${ESP_VERSION_MINOR}) | ||
set(ESP_SUBMINOR_VERSION ${ESP_VERSION_PATCH}) | ||
|
||
# Define ESP version in x.y.z format | ||
set(ESP_VERSION_STRING "${ESP_VERSION_MAJOR}.${ESP_VERSION_MINOR}.${ESP_VERSION_PATCH}") | ||
|
||
# message(STATUS "ESP Version: ${ESP_VERSION_STRING}") | ||
endif() | ||
|
||
# ------------------------------------------------------------------------ | ||
# Begin finding ESP libraries | ||
# ------------------------------------------------------------------------ | ||
|
||
# all potential ESP components | ||
set(ESP_COMPONENTS caps egads ocsm) | ||
|
||
# if not explicitly asking for any component, find all of them | ||
if(NOT ESP_FIND_COMPONENTS) | ||
set(ESP_FIND_COMPONENTS ${ESP_COMPONENTS}) | ||
endif() | ||
|
||
foreach(component ${ESP_FIND_COMPONENTS}) | ||
|
||
if(component STREQUAL "egads") | ||
if (ESP_USE_EGADSLITE) | ||
find_library(egads_LIBRARY NAMES egadslite) | ||
else() | ||
find_library(egads_LIBRARY NAMES egads) | ||
endif() | ||
else() | ||
find_library(${component}_LIBRARY NAMES ${component}) | ||
endif() | ||
|
||
if(${component}_LIBRARY) | ||
set(ESP_${component}_FOUND True) | ||
else() | ||
set(ESP_${component}_FOUND False) | ||
endif() | ||
|
||
# Create a library target only if the above checks passed | ||
if(ESP_${component}_FOUND AND NOT TARGET ESP::${component}) | ||
# Can't easily tell how ESP was compiled, so just default to UNKNOWN | ||
# library type and CMake will make a best effort guess | ||
add_library(ESP::${component} UNKNOWN IMPORTED) | ||
|
||
set_property( | ||
TARGET ESP::${component} PROPERTY | ||
INTERFACE_INCLUDE_DIRECTORIES "${ESP_INCLUDE_DIR}" | ||
) | ||
if(EXISTS "${${component}_LIBRARY}") | ||
set_property( | ||
TARGET ESP::${component} PROPERTY | ||
IMPORTED_LOCATION "${${component}_LIBRARY}" | ||
) | ||
endif() | ||
endif() | ||
endforeach() | ||
|
||
# Create INTERFACE target that bundles all the found libraries together | ||
if(NOT TARGET ESP::ESP) | ||
add_library(ESP::ESP INTERFACE IMPORTED) | ||
foreach(component ${ESP_FIND_COMPONENTS}) | ||
if(TARGET ESP::${component}) | ||
target_link_libraries(ESP::ESP INTERFACE ESP::${component}) | ||
endif() | ||
endforeach() | ||
endif() | ||
|
||
# Use CMake provided module to check the variables | ||
include(FindPackageHandleStandardArgs) | ||
find_package_handle_standard_args(ESP | ||
REQUIRED_VARS ESP_INCLUDE_DIR | ||
VERSION_VAR ESP_VERSION_STRING | ||
HANDLE_COMPONENTS | ||
) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
To add compiler definitions you should be
target_compile_definitions
. Since you use this option in the header it will need to be public. Because this leaks into the user's downstream code you should use a prefixed name. I.e.PUMI_HAVE_EGADS
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Thanks for taking another look at this @jacobmerson. I wrote the
-DHAVE_EGADS
definition to be consistent with the simmetrix definition:core/CMakeLists.txt
Lines 97 to 99 in 30a332d
Based on the way that
HAVE_SIMMETRIX
is used, it seems convenient to useadd_definitions
so that it applies to all the executables so that multiple calls totarget_compile_definitions
can be skipped, but I am aware that this approach is considered bad practice in modern cmake. In any case I thought it would be best to stay consistent, though I'm not tied to the current approach.There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I would prefer that all of those other
HAVE_XXX
definitions get prefixed eventually and you have a valid point about consistency. The problem with adding compile definitions without a namespace is that any other consuming project linking againstpumi_egads
has that compile definition on their target. So, what if a consumer wants to use PUMI compiled with egads but they have conditional code behindHAVE_EGADS
that they don't want to compile for some reason...currently they cannot do that since compile definitions are infectious. I think @cwsmith has last word on this sort of thing since he has to deal with all the xsdk people/rules.The issue with the non-target version of
add_definitions
(especially in the top level cmake file) is that it will be applied to every single target and library at the current or lower sub-directory level. So, even random libraries that have nothing to do with egads are getting that compile definition added. Since these compile definitions will be infectious to anyone who uses any SCOREC target it has the potential to cause issues for down stream users.There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
@cwsmith do you have any thoughts on the concerns raised by @jacobmerson?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
@jacobmerson is correct. We should have all the
*HAVE*
,*ENABLE*
, etc... variables prefixed withPUMI_
to avoid conflicts with packages that use PUMI. +1 for usingtarget_compile_definitions
as well.I created an issue to clean this up in
develop
after this is merged. #337