Skip to content

Commit 33c4198

Browse files
Updated cmake and build files to work with new FEBioConfig.cmake
1 parent abedfe8 commit 33c4198

4 files changed

Lines changed: 7 additions & 129 deletions

File tree

CMakeLists.txt

Lines changed: 4 additions & 126 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
cmake_minimum_required(VERSION 3.10)
1+
cmake_minimum_required(VERSION 3.15)
22
set(CMAKE_CXX_STANDARD 17)
33
set(CMAKE_CXX_STANDARD_REQUIRED ON)
44
mark_as_advanced(FORCE CMAKE_INSTALL_PREFIX)
@@ -7,7 +7,6 @@ project(FEBioWarp)
77

88
set(CMAKE_LIBRARY_OUTPUT_DIRECTORY ${CMAKE_BINARY_DIR}/lib)
99

10-
1110
set_property(GLOBAL PROPERTY USE_FOLDERS ON)
1211

1312
# Set a default build type if none was specified
@@ -22,128 +21,15 @@ if(NOT CMAKE_BUILD_TYPE AND NOT CMAKE_CONFIGURATION_TYPES)
2221
"Debug" "Release" "MinSizeRel" "RelWithDebInfo")
2322
endif()
2423

25-
# Find FEBio SDK or git repo automatically
26-
if(WIN32)
27-
add_definitions(-DWIN32 -DFECORE_DLL)
28-
set(TEMP_PATHS ${CMAKE_SOURCE_DIR}/.. ${CMAKE_SOURCE_DIR}/../.. $ENV{HOMEPATH}/ $ENV{HOMEPATH}/source/repos $ENV{HOMEPATH}/*)
29-
else()
30-
set(TEMP_PATHS ${CMAKE_SOURCE_DIR}/.. ${CMAKE_SOURCE_DIR}/../.. $ENV{HOME}/ $ENV{HOME}/*)
31-
endif()
32-
33-
find_path(FEBio_SDK FECore/Archive.h
34-
PATHS ${TEMP_PATHS}
35-
PATH_SUFFIXES FEBio
36-
DOC "Path to the FEBio SDK, or git repo.")
37-
38-
if(NOT FEBio_SDK)
39-
if(WIN32)
40-
set(TEMP_PATHS $ENV{PROGRAMFILES}/* $ENV{HOMEPATH}/*)
41-
elseif(APPLE)
42-
set(TEMP_PATHS /Applications/* $ENV{HOME}/*)
43-
else()
44-
set(TEMP_PATHS $ENV{HOME}/*)
45-
endif()
46-
47-
find_path(FEBio_SDK "include/FECore/Archive.h"
48-
PATHS ${TEMP_PATHS}
49-
PATH_SUFFIXES sdk
50-
DOC "Path to the FEBio SDK, or git repo.")
51-
endif()
52-
53-
if(NOT FEBio_SDK)
54-
set(FEBio_SDK "" CACHE PATH "Path to the FEBio SDK, or git repo.")
55-
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.")
56-
endif()
57-
58-
# Only update the include and lib directories if the FEBio_SDK path has been changed.
59-
if(NOT OLD_SDK)
60-
set(NEWPATH TRUE)
61-
else()
62-
string(COMPARE NOTEQUAL ${FEBio_SDK} ${OLD_SDK} NEWPATH)
63-
endif()
64-
65-
if(NEWPATH)
66-
# Is this the SDK?
67-
string(REGEX MATCH "sdk" IS_SDK ${FEBio_SDK})
68-
69-
set(LIB_SUFFIXES "")
70-
if(IS_SDK)
71-
set(FEBio_INC "${FEBio_SDK}/include" CACHE PATH "Path to FEBio include directory." FORCE)
72-
73-
list(APPEND LIB_SUFFIXES "lib" "lib/Release" "lib/Debug")
74-
else()
75-
set(FEBio_INC ${FEBio_SDK} CACHE PATH "Path to FEBio include directory." FORCE)
76-
77-
if(WIN32)
78-
list(APPEND LIB_SUFFIXES "cmbuild22/lib/Debug" "cmbuild/lib/Release" "cmbuild/lib/Debug" "cbuild/lib/Release" "cbuild/lib/Debug" "build/lib/Release" "build/lib/Debug")
79-
else()
80-
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")
81-
endif()
82-
endif()
83-
84-
mark_as_advanced(FEBio_INC)
85-
86-
# Find lib path
87-
find_library(FECORE
88-
NAMES FECore fecore fecore_gcc64 fecore_lnx64
89-
PATHS ${FEBio_SDK}
90-
PATH_SUFFIXES ${LIB_SUFFIXES}
91-
DOC "FEBio library path")
92-
93-
if(FECORE)
94-
get_filename_component(FECORE_TEMP ${FECORE} DIRECTORY)
95-
set(FEBio_LIB_DIR ${FECORE_TEMP} CACHE PATH "Path to the FEBio lib directory." FORCE)
96-
mark_as_advanced(FEBio_LIB_DIR)
97-
unset(FECORE_TEMP)
98-
unset(FECORE CACHE)
99-
else()
100-
set(FEBio_LIB_DIR CACHE PATH "Path to the FEBio lib directory." FORCE)
101-
message(SEND_ERROR "Unable to find FEBio Library path automatically. Set FEBio_LIB_DIR.")
102-
unset(FECORE CACHE)
103-
endif()
104-
endif()
105-
106-
set(OLD_SDK ${FEBio_SDK} CACHE PATH "Don't edit. Old SDK path used to automatically make changes." FORCE)
107-
mark_as_advanced(OLD_SDK)
108-
109-
#### Check if paths are valid and find libs ####
110-
function(findLib libName libDir libOut)
111-
string(TOLOWER ${libName} lname)
112-
113-
find_library(TEMP
114-
NAMES ${libName} ${lname} ${lname}_gcc64 ${lname}_lnx64
115-
PATHS ${${libDir}}
116-
NO_DEFAULT_PATH)
117-
118-
if(TEMP)
119-
set(${libOut} ${TEMP} PARENT_SCOPE)
120-
unset(TEMP CACHE)
121-
else()
122-
if(WIN32)
123-
message(SEND_ERROR "Could not find ${libName}.lib. Check ${libName}.")
124-
elseif(APPLE)
125-
message(SEND_ERROR "Could not find ${libName}.so, ${libName}.a, or ${libName}.dylib Check ${libDir}.")
126-
else()
127-
message(SEND_ERROR "Could not find ${libName}.so, or ${libName}.a. Check ${libDir}")
128-
endif()
129-
unset(TEMP CACHE)
130-
endif()
131-
endfunction()
132-
133-
if(FEBio_LIB_DIR)
134-
findLib(FECore FEBio_LIB_DIR FECORE)
135-
findLib(FEBioMech FEBio_LIB_DIR FEBIOMECH)
136-
findLib(FEImgLib FEBio_LIB_DIR FEIMGLIB)
137-
findLib(FEBioXML FEBio_LIB_DIR FEBIOXML)
138-
endif()
24+
find_package(FEBio REQUIRED)
13925

14026
##### Set appropriate defines and includes #####
14127

14228
if(WIN32)
14329
add_definitions(-DWIN32 /MP /openmp)
14430
elseif(APPLE)
14531
add_definitions(-D__APPLE__)
146-
set(CMAKE_OSX_DEPLOYMENT_TARGET 10.13)
32+
set(CMAKE_OSX_DEPLOYMENT_TARGET 10.15)
14733
else()
14834
add_definitions(-DLINUX)
14935
add_compile_options(-static-libstdc++ -static-libgcc -w -Wall)
@@ -152,13 +38,6 @@ else()
15238
set(CMAKE_BUILD_RPATH $ORIGIN/../lib/)
15339
endif()
15440

155-
# Extra compiler flags for intel compiler
156-
if("${CMAKE_CXX_COMPILER_ID}" STREQUAL "Intel")
157-
set(CMAKE_SHARED_LINKER_FLAGS ${CMAKE_SHARED_LINKER_FLAGS} -static-intel)
158-
endif()
159-
160-
include_directories(${FEBio_INC})
161-
16241
##### Add library #####
16342

16443
file(GLOB HDR_FEBioWarp "FEWarp/*.h")
@@ -169,5 +48,4 @@ set_property(TARGET FEBioWarp PROPERTY AUTOGEN_BUILD_DIR ${CMAKE_BINARY_DIR}/CMa
16948

17049
##### Link Libraries #####
17150

172-
target_link_libraries(FEBioWarp ${FECORE} ${FEBIOMECH} ${FEIMGLIB} ${FEBIOXML})
173-
51+
target_link_libraries(FEBioWarp FEBio::FECore FEBio::FEBioMech FEBio::FEImgLib FEBio::FEBioXML)

ci/Linux/cmake.sh

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -5,5 +5,5 @@ FEBIO_SDK="$(realpath $FEBIO_SDK)"
55

66
run_cmake() {
77
cmake -L . -B cmbuild \
8-
-DFEBio_SDK=$FEBIO_SDK
8+
-DCMAKE_PREFIX_PATH=$FEBIO_SDK
99
}

ci/Windows/build.bat

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -10,7 +10,7 @@ cd %SCRIPTDIR%\..\..\
1010
if not defined FEBIO_SDK set "FEBIO_SDK=%STARTDIR%\febio4-sdk"
1111

1212
cmake -L . -B cmbuild ^
13-
-DFEBio_SDK=%FEBIO_SDK%
13+
-DCMAKE_PREFIX_PATH=%FEBIO_SDK%
1414

1515
cd cmbuild
1616
msbuild /P:Configuration=Release /P:WarningLevel=0 /m:%PROC% ALL_BUILD.vcxproj

ci/macOS/cmake.sh

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,6 @@ FEBIO_SDK="${FEBIO_SDK:-febio4-sdk}"
22
FEBIO_SDK="$(realpath $FEBIO_SDK)"
33
run_cmake() {
44
cmake -L . -B cmbuild \
5-
-DFEBio_SDK=$FEBIO_SDK \
5+
-DCMAKE_PREFIX_PATH=$FEBIO_SDK \
66
-DCMAKE_OSX_ARCHITECTURES=x86_64
77
}

0 commit comments

Comments
 (0)