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