1- cmake_minimum_required (VERSION 3.10 )
1+ cmake_minimum_required (VERSION 3.15 )
22
33set (CMAKE_CXX_STANDARD 11)
44set (CMAKE_CXX_STANDARD_REQUIRED ON )
@@ -21,95 +21,7 @@ if(NOT CMAKE_BUILD_TYPE AND NOT CMAKE_CONFIGURATION_TYPES)
2121 "Debug" "Release" "MinSizeRel" "RelWithDebInfo" )
2222endif ()
2323
24- # Find FEBio SDK or git repo automatically
25- if (WIN32 )
26- set (TEMP_PATHS ${CMAKE_SOURCE_DIR} /.. ${CMAKE_SOURCE_DIR} /../.. $ENV{HOMEPATH} / $ENV{HOMEPATH} /source/repos $ENV{HOMEPATH} /*)
27- else ()
28- set (TEMP_PATHS ${CMAKE_SOURCE_DIR} /.. ${CMAKE_SOURCE_DIR} /../.. $ENV{HOME} / $ENV{HOME} /*)
29- endif ()
30-
31- find_path (FEBio_SDK FECore/Archive.h
32- PATHS ${TEMP_PATHS}
33- PATH_SUFFIXES FEBio
34- DOC "Path to the FEBio SDK, or git repo." )
35-
36- if (NOT FEBio_SDK)
37- if (WIN32 )
38- set (TEMP_PATHS $ENV{PROGRAMFILES} /* $ENV{HOMEPATH} /*)
39- elseif (APPLE )
40- set (TEMP_PATHS /Applications/* $ENV{HOME} /*)
41- else ()
42- set (TEMP_PATHS $ENV{HOME} /*)
43- endif ()
44-
45- find_path (FEBio_SDK "include/FECore/Archive.h"
46- PATHS ${TEMP_PATHS}
47- PATH_SUFFIXES sdk
48- DOC "Path to the FEBio SDK, or git repo." )
49- endif ()
50-
51- if (NOT FEBio_SDK)
52- set (FEBio_SDK "" CACHE PATH "Path to the FEBio SDK, or git repo." )
53- message (FATAL_ERROR "Unable to find path to FEBio SDK or git repo automatically. Please set FEBio_SDK to the path to your FEBio SDK or git repo." )
54- endif ()
55-
56- # Only update the include and lib directories if the FEBio_SDK path has been changed.
57- if (NOT OLD_SDK)
58- set (NEWPATH TRUE )
59- else ()
60- #cmake_path(CONVERT ${OLD_SDK} TO_CMAKE_PATH_LIST STD_OLD_SDK)
61- #cmake_path(CONVERT ${FEBio_SDK} TO_CMAKE_PATH_LIST STD_FEBIO_SDK)
62- #string(COMPARE NOTEQUAL ${STD_FEBIO_SDK} ${STD_OLD_SDK} NEWPATH)
63- string (COMPARE NOTEQUAL ${FEBio_SDK} ${OLD_SDK} NEWPATH)
64- endif ()
65-
66- if (NEWPATH)
67- # Is this the SDK?
68- string (REGEX MATCH "sdk" IS_SDK ${FEBio_SDK} )
69-
70- set (LIB_SUFFIXES "" )
71- if (IS_SDK)
72- set (FEBio_INC "${FEBio_SDK} /include" CACHE PATH "Path to FEBio include directory." FORCE )
73-
74- if (WIN32 )
75- list (APPEND LIB_SUFFIXES "lib/Release" "lib/Debug" "lib" )
76- else ()
77- list (APPEND LIB_SUFFIXES "lib" )
78- endif ()
79- else ()
80- set (FEBio_INC ${FEBio_SDK} CACHE PATH "Path to FEBio include directory." FORCE )
81-
82- if (WIN32 )
83- list (APPEND LIB_SUFFIXES "cmbuild22/lib/Release" "cmbuild/lib/Release" "cmbuild/lib/Debug" "cbuild/lib/Release" "cbuild/lib/Debug" "build/lib/Release" "build/lib/Debug" )
84- else ()
85- list (APPEND LIB_SUFFIXES "cbuild/lib" "cmbuild/lib" "build/lib" "cbuild/Release/lib" "cmbuild/Release/lib" "build/Release/lib" "cbuild/Debug/lib" "cmbuild/Debug/lib" "build/Debug/lib" )
86- endif ()
87- endif ()
88-
89- mark_as_advanced (FEBio_INC )
90-
91- # Find lib path
92- find_library (FECORE
93- NAMES FECore fecore fecore_gcc64 fecore_lnx64
94- PATHS ${FEBio_SDK}
95- PATH_SUFFIXES ${LIB_SUFFIXES}
96- DOC "FEBio library path" )
97-
98- if (FECORE)
99- get_filename_component (FECORE_TEMP ${FECORE} DIRECTORY )
100- set (FEBio_LIB_DIR ${FECORE_TEMP} CACHE PATH "Path to the FEBio lib directory." FORCE )
101- mark_as_advanced (FEBio_LIB_DIR )
102- unset (FECORE_TEMP)
103- unset (FECORE CACHE )
104- else ()
105- set (FEBio_LIB_DIR CACHE PATH "Path to the FEBio lib directory." FORCE )
106- message (SEND_ERROR "Unable to find FEBio Library path automatically. Set FEBio_LIB_DIR." )
107- unset (FECORE CACHE )
108- endif ()
109- endif ()
110-
111- set (OLD_SDK ${FEBio_SDK} CACHE PATH "Don't edit. Old SDK path used to automatically make changes." FORCE )
112- mark_as_advanced (OLD_SDK )
24+ find_package (FEBio REQUIRED )
11325
11426#### Check if paths are valid and find libs ####
11527function (findLib libName libDir libOut )
@@ -135,11 +47,6 @@ function(findLib libName libDir libOut)
13547 endif ()
13648endfunction ()
13749
138- if (FEBio_LIB_DIR)
139- findLib (FECore FEBio_LIB_DIR FECORE )
140- findLib (FEBioMech FEBio_LIB_DIR FEBIOMECH )
141- endif ()
142-
14350##### Set appropriate defines and includes #####
14451
14552if (WIN32 )
@@ -156,13 +63,6 @@ else()
15663 set (CMAKE_BUILD_RPATH $ORIGIN/../lib/)
15764endif ()
15865
159- # Extra compiler flags for intel compiler
160- if ("${CMAKE_CXX_COMPILER_ID} " STREQUAL "Intel" )
161- set (CMAKE_SHARED_LINKER_FLAGS ${CMAKE_SHARED_LINKER_FLAGS} -static-intel)
162- endif ()
163-
164- include_directories (${FEBio_INC} )
165-
16666##### Add library #####
16767
16868file (GLOB HDR_FEBioChem "FEBioChem/*.h" )
@@ -173,4 +73,4 @@ set_property(TARGET FEBioChem PROPERTY AUTOGEN_BUILD_DIR ${CMAKE_BINARY_DIR}/CMa
17373
17474##### Link Libraries #####
17575
176- target_link_libraries (FEBioChem ${FECORE} )
76+ target_link_libraries (FEBioChem FEBio::FECore )
0 commit comments