Refactor SimGear detection to correctly select debug vs release builds in shared library mode.
This commit is contained in:
parent
f356854712
commit
cdc65753f0
1 changed files with 40 additions and 46 deletions
|
@ -27,13 +27,11 @@
|
||||||
|
|
||||||
include(SelectLibraryConfigurations)
|
include(SelectLibraryConfigurations)
|
||||||
|
|
||||||
macro(find_sg_component comp libs)
|
macro(find_sg_library libName varName libs)
|
||||||
set(compLib "sg${comp}")
|
set(libVarName "${varName}_LIBRARY")
|
||||||
string(TOUPPER "SIMGEAR_${comp}" compLibBase)
|
|
||||||
set( compLibName ${compLibBase}_LIBRARY )
|
|
||||||
|
|
||||||
FIND_LIBRARY(${compLibName}_DEBUG
|
FIND_LIBRARY(${libVarName}_DEBUG
|
||||||
NAMES ${compLib}${CMAKE_DEBUG_POSTFIX}
|
NAMES ${libName}${CMAKE_DEBUG_POSTFIX}
|
||||||
HINTS $ENV{SIMGEAR_DIR}
|
HINTS $ENV{SIMGEAR_DIR}
|
||||||
PATH_SUFFIXES ${CMAKE_INSTALL_LIBDIR} libs64 libs libs/Win32 libs/Win64
|
PATH_SUFFIXES ${CMAKE_INSTALL_LIBDIR} libs64 libs libs/Win32 libs/Win64
|
||||||
PATHS
|
PATHS
|
||||||
|
@ -41,8 +39,8 @@ macro(find_sg_component comp libs)
|
||||||
/usr
|
/usr
|
||||||
/opt
|
/opt
|
||||||
)
|
)
|
||||||
FIND_LIBRARY(${compLibName}_RELEASE
|
FIND_LIBRARY(${libVarName}_RELEASE
|
||||||
NAMES ${compLib}${CMAKE_RELEASE_POSTFIX}
|
NAMES ${libName}${CMAKE_RELEASE_POSTFIX}
|
||||||
HINTS $ENV{SIMGEAR_DIR}
|
HINTS $ENV{SIMGEAR_DIR}
|
||||||
PATH_SUFFIXES ${CMAKE_INSTALL_LIBDIR} libs64 libs libs/Win32 libs/Win64
|
PATH_SUFFIXES ${CMAKE_INSTALL_LIBDIR} libs64 libs libs/Win32 libs/Win64
|
||||||
PATHS
|
PATHS
|
||||||
|
@ -50,14 +48,22 @@ macro(find_sg_component comp libs)
|
||||||
/usr
|
/usr
|
||||||
/opt
|
/opt
|
||||||
)
|
)
|
||||||
select_library_configurations( ${compLibBase} )
|
|
||||||
|
|
||||||
set(componentLibRelease ${${compLibName}_RELEASE})
|
# message(STATUS "before: Simgear ${${libVarName}_RELEASE} ")
|
||||||
#message(STATUS "Simgear ${compLibName}_RELEASE ${componentLibRelease}")
|
# message(STATUS "before: Simgear ${${libVarName}_DEBUG} ")
|
||||||
set(componentLibDebug ${${compLibName}_DEBUG})
|
|
||||||
#message(STATUS "Simgear ${compLibName}_DEBUG ${componentLibDebug}")
|
select_library_configurations( ${varName} )
|
||||||
if (NOT ${compLibName}_DEBUG)
|
|
||||||
if (NOT ${compLibName}_RELEASE)
|
# message(STATUS "after:Simgear ${${libVarName}_RELEASE} ")
|
||||||
|
# message(STATUS "after:Simgear ${${libVarName}_DEBUG} ")
|
||||||
|
|
||||||
|
set(componentLibRelease ${${libVarName}_RELEASE})
|
||||||
|
# message(STATUS "Simgear ${libVarName}_RELEASE ${componentLibRelease}")
|
||||||
|
set(componentLibDebug ${${libVarName}_DEBUG})
|
||||||
|
# message(STATUS "Simgear ${libVarName}_DEBUG ${componentLibDebug}")
|
||||||
|
|
||||||
|
if (NOT ${libVarName}_DEBUG)
|
||||||
|
if (NOT ${libVarName}_RELEASE)
|
||||||
#message(STATUS "found ${componentLib}")
|
#message(STATUS "found ${componentLib}")
|
||||||
list(APPEND ${libs} ${componentLibRelease})
|
list(APPEND ${libs} ${componentLibRelease})
|
||||||
endif()
|
endif()
|
||||||
|
@ -66,6 +72,13 @@ macro(find_sg_component comp libs)
|
||||||
endif()
|
endif()
|
||||||
endmacro()
|
endmacro()
|
||||||
|
|
||||||
|
macro(find_sg_component comp libs)
|
||||||
|
set(compLib "sg${comp}")
|
||||||
|
string(TOUPPER "SIMGEAR_${comp}" libVar)
|
||||||
|
|
||||||
|
find_sg_library(${compLib} ${libVar} ${libs})
|
||||||
|
endmacro()
|
||||||
|
|
||||||
FIND_PATH(SIMGEAR_INCLUDE_DIR simgear/math/SGMath.hxx
|
FIND_PATH(SIMGEAR_INCLUDE_DIR simgear/math/SGMath.hxx
|
||||||
HINTS $ENV{SIMGEAR_DIR}
|
HINTS $ENV{SIMGEAR_DIR}
|
||||||
PATH_SUFFIXES include
|
PATH_SUFFIXES include
|
||||||
|
@ -77,7 +90,7 @@ FIND_PATH(SIMGEAR_INCLUDE_DIR simgear/math/SGMath.hxx
|
||||||
/opt
|
/opt
|
||||||
)
|
)
|
||||||
|
|
||||||
message(STATUS ${SIMGEAR_INCLUDE_DIR})
|
# message(STATUS ${SIMGEAR_INCLUDE_DIR})
|
||||||
|
|
||||||
# dependent packages
|
# dependent packages
|
||||||
find_package(ZLIB REQUIRED)
|
find_package(ZLIB REQUIRED)
|
||||||
|
@ -86,38 +99,16 @@ find_package(Threads REQUIRED)
|
||||||
if(SIMGEAR_SHARED)
|
if(SIMGEAR_SHARED)
|
||||||
message(STATUS "looking for shared Simgear libraries")
|
message(STATUS "looking for shared Simgear libraries")
|
||||||
|
|
||||||
# check for dynamic framework/library (experimental!)
|
find_sg_library(SimGearCore SIMGEAR_CORE SIMGEAR_CORE_LIBRARIES)
|
||||||
FIND_LIBRARY(SIMGEAR_SHARED_CORE_LIBRARY
|
find_sg_library(SimGearScene SIMGEAR_SCENE SIMGEAR_LIBRARIES)
|
||||||
NAMES simgearCore SimGearCore
|
|
||||||
HINTS
|
|
||||||
$ENV{SIMGEAR_DIR}
|
|
||||||
PATH_SUFFIXES ${CMAKE_INSTALL_LIBDIR} libs64 libs libs/Win32 libs/Win64
|
|
||||||
PATHS
|
|
||||||
~/Library/Frameworks
|
|
||||||
/Library/Frameworks
|
|
||||||
/usr/local
|
|
||||||
/usr
|
|
||||||
/opt
|
|
||||||
)
|
|
||||||
|
|
||||||
FIND_LIBRARY(SIMGEAR_SHARED_SCENE_LIBRARY
|
|
||||||
NAMES simgearScene SimGearScene
|
|
||||||
HINTS
|
|
||||||
$ENV{SIMGEAR_DIR}
|
|
||||||
PATH_SUFFIXES ${CMAKE_INSTALL_LIBDIR} libs64 libs libs/Win32 libs/Win64
|
|
||||||
PATHS
|
|
||||||
~/Library/Frameworks
|
|
||||||
/Library/Frameworks
|
|
||||||
/usr/local
|
|
||||||
/usr
|
|
||||||
/opt
|
|
||||||
)
|
|
||||||
|
|
||||||
set(SIMGEAR_CORE_LIBRARIES ${SIMGEAR_SHARED_CORE_LIBRARY})
|
list(APPEND SIMGEAR_LIBRARIES ${SIMGEAR_CORE_LIBRARIES})
|
||||||
set(SIMGEAR_LIBRARIES ${SIMGEAR_SHARED_SCENE_LIBRARY} ${SIMGEAR_SHARED_CORE_LIBRARY})
|
|
||||||
set(SIMGEAR_CORE_LIBRARY_DEPENDENCIES "")
|
set(SIMGEAR_CORE_LIBRARY_DEPENDENCIES "")
|
||||||
set(SIMGEAR_SCENE_LIBRARY_DEPENDENCIES "")
|
set(SIMGEAR_SCENE_LIBRARY_DEPENDENCIES "")
|
||||||
|
|
||||||
|
# message(STATUS "core lib ${SIMGEAR_CORE_LIBRARIES}")
|
||||||
|
# message(STATUS "all libs ${SIMGEAR_LIBRARIES}")
|
||||||
else(SIMGEAR_SHARED)
|
else(SIMGEAR_SHARED)
|
||||||
|
|
||||||
set(SIMGEAR_LIBRARIES "") # clear value
|
set(SIMGEAR_LIBRARIES "") # clear value
|
||||||
|
@ -165,9 +156,12 @@ else(SIMGEAR_SHARED)
|
||||||
find_sg_component(${component} SIMGEAR_LIBRARIES)
|
find_sg_component(${component} SIMGEAR_LIBRARIES)
|
||||||
endforeach()
|
endforeach()
|
||||||
|
|
||||||
# again link order matters - scene libraires depend on core ones
|
|
||||||
|
# again link order matters - scene libraries depend on core ones
|
||||||
list(APPEND SIMGEAR_LIBRARIES ${SIMGEAR_CORE_LIBRARIES})
|
list(APPEND SIMGEAR_LIBRARIES ${SIMGEAR_CORE_LIBRARIES})
|
||||||
|
|
||||||
|
#message(STATUS "all libs ${SIMGEAR_LIBRARIES}")
|
||||||
|
|
||||||
set(SIMGEAR_CORE_LIBRARY_DEPENDENCIES
|
set(SIMGEAR_CORE_LIBRARY_DEPENDENCIES
|
||||||
${CMAKE_THREAD_LIBS_INIT}
|
${CMAKE_THREAD_LIBS_INIT}
|
||||||
${ZLIB_LIBRARY})
|
${ZLIB_LIBRARY})
|
||||||
|
|
Loading…
Reference in a new issue