cmake: update FindFX module
This commit is contained in:
+18
-10
@@ -51,15 +51,7 @@ endif ()
|
||||
|
||||
set(assemblies ${FX_FIND_COMPONENTS})
|
||||
set(required_vars)
|
||||
|
||||
if (NOT FX_INCLUDE_DIR)
|
||||
find_path(FX_INCLUDE_DIR
|
||||
NAMES fx/misc.h ${FX_FIND_ARGS}
|
||||
PATH_SUFFIXES include
|
||||
PATHS ${FX_SEARCH_PATHS})
|
||||
endif ()
|
||||
|
||||
set(required_vars FX_INCLUDE_DIR)
|
||||
set(in_tree FALSE)
|
||||
|
||||
foreach (assembly ${assemblies})
|
||||
string(TOLOWER ${assembly} header_name)
|
||||
@@ -69,10 +61,15 @@ foreach (assembly ${assemblies})
|
||||
set(lib_name ${assembly}${_lib_suffix})
|
||||
|
||||
if (NOT ${macro_name}_LIBRARY)
|
||||
if (TARGET ${assembly})
|
||||
set (${macro_name}_LIBRARY ${assembly})
|
||||
set(in_tree TRUE)
|
||||
else ()
|
||||
find_library(${macro_name}_LIBRARY
|
||||
NAMES ${lib_name} ${FX_FIND_ARGS}
|
||||
PATH_SUFFIXES lib
|
||||
PATHS ${FX_SEARCH_PATHS})
|
||||
endif ()
|
||||
else ()
|
||||
# on Windows, ensure paths are in canonical format (forward slahes):
|
||||
file(TO_CMAKE_PATH "${${macro_name}_LIBRARY}" ${macro_name}_LIBRARY)
|
||||
@@ -81,6 +78,14 @@ foreach (assembly ${assemblies})
|
||||
list(APPEND required_vars ${macro_name}_LIBRARY)
|
||||
endforeach (assembly)
|
||||
|
||||
if (NOT FX_INCLUDE_DIR AND NOT in_tree)
|
||||
list(APPEND required_vars FX_INCLUDE_DIR)
|
||||
find_path(FX_INCLUDE_DIR
|
||||
NAMES fx/misc.h ${FX_FIND_ARGS}
|
||||
PATH_SUFFIXES include
|
||||
PATHS ${FX_SEARCH_PATHS})
|
||||
endif ()
|
||||
|
||||
unset(FX_FIND_ARGS)
|
||||
|
||||
include(FindPackageHandleStandardArgs)
|
||||
@@ -106,6 +111,9 @@ if (FX_FOUND)
|
||||
set(lib_name ${assembly}${_lib_suffix})
|
||||
|
||||
if (NOT TARGET FX::${target_name})
|
||||
if (TARGET ${assembly})
|
||||
add_library(FX::${target_name} ALIAS ${assembly})
|
||||
else ()
|
||||
add_library(FX::${target_name} UNKNOWN IMPORTED)
|
||||
set_target_properties(FX::${target_name} PROPERTIES
|
||||
INTERFACE_INCLUDE_DIRECTORIES "${FX_INCLUDE_DIR}")
|
||||
@@ -114,10 +122,10 @@ if (FX_FOUND)
|
||||
if (FX_STATIC)
|
||||
target_compile_definitions(FX::${target_name} INTERFACE FX_STATIC=1)
|
||||
endif ()
|
||||
|
||||
set_target_properties(FX::${target_name} PROPERTIES
|
||||
IMPORTED_LINK_INTERFACE_LANGUAGES "C"
|
||||
IMPORTED_LOCATION "${${macro_name}_LIBRARY}")
|
||||
endif ()
|
||||
set(created_targets ${created_targets} ${assembly})
|
||||
endif ()
|
||||
endforeach (assembly)
|
||||
|
||||
Reference in New Issue
Block a user