Properly link flecs library
This commit is contained in:
@@ -0,0 +1,48 @@
|
||||
|
||||
macro(list_targets RESULT)
|
||||
file(GLOB_RECURSE FILES LIST_DIRECTORIES true RELATIVE ${CUR_DIR} *)
|
||||
set(TARGET_LIST "")
|
||||
|
||||
foreach (FILE ${FILES})
|
||||
if (IS_DIRECTORY ${CUR_DIR}/${FILE})
|
||||
if (EXISTS ${CUR_DIR}/${FILE}/project.json)
|
||||
message(STATUS "Found example ${FILE}")
|
||||
list(APPEND TARGET_LIST ${FILE})
|
||||
endif()
|
||||
endif ()
|
||||
endforeach ()
|
||||
|
||||
set(${RESULT} ${TARGET_LIST})
|
||||
endmacro()
|
||||
|
||||
macro(create_target TARGET CONFIG)
|
||||
if (CONFIG STREQUAL "")
|
||||
set(TARGET_POSTFIX "")
|
||||
else()
|
||||
set(TARGET_POSTFIX "_${CONFIG}")
|
||||
endif()
|
||||
|
||||
set(TARGET_NAME "${TARGET}${TARGET_POSTFIX}")
|
||||
string(REPLACE "/" "_" TARGET_NAME "${TARGET_NAME}")
|
||||
string(REPLACE "\\" "_" TARGET_NAME "${TARGET_NAME}")
|
||||
set(TARGET_DIR "${CUR_DIR}/${TARGET}")
|
||||
|
||||
file(GLOB SRC ${TARGET_DIR}/src/*.c*)
|
||||
add_executable(${TARGET_NAME} ${SRC})
|
||||
|
||||
target_include_directories(${TARGET_NAME} PUBLIC ${FLECS_DIR}/include)
|
||||
target_include_directories(${TARGET_NAME} PUBLIC ${TARGET_DIR}/include)
|
||||
target_link_libraries(${TARGET_NAME} flecs${TARGET_POSTFIX})
|
||||
endmacro()
|
||||
|
||||
function(create_target_c TARGET CONFIG)
|
||||
create_target("${TARGET}" "${CONFIG}")
|
||||
target_default_compile_options_c(${TARGET_NAME})
|
||||
target_default_compile_warnings_c(${TARGET_NAME})
|
||||
endfunction()
|
||||
|
||||
function(create_target_cxx TARGET CONFIG)
|
||||
create_target("${TARGET}" "${CONFIG}")
|
||||
target_default_compile_options_cxx(${TARGET_NAME})
|
||||
target_default_compile_warnings_cxx(${TARGET_NAME})
|
||||
endfunction()
|
||||
26
engine/libs/flecs/cmake/target_default_compile_options.cmake
Normal file
26
engine/libs/flecs/cmake/target_default_compile_options.cmake
Normal file
@@ -0,0 +1,26 @@
|
||||
set(CMAKE_C_STANDARD 99)
|
||||
set(CMAKE_C_STANDARD_REQUIRED ON)
|
||||
|
||||
set(CMAKE_CXX_STANDARD 11)
|
||||
set(CMAKE_CXX_STANDARD_REQUIRED ON)
|
||||
|
||||
option(FLECS_STRICT "Stricter warning options and Werror" OFF)
|
||||
|
||||
function(target_default_compile_options_c THIS)
|
||||
|
||||
set_target_properties(${THIS} PROPERTIES
|
||||
LINKER_LANGUAGE C
|
||||
C_STANDARD 99
|
||||
C_STANDARD_REQUIRED ON
|
||||
C_VISIBILITY_PRESET hidden)
|
||||
|
||||
endfunction()
|
||||
|
||||
function(target_default_compile_options_cxx THIS)
|
||||
|
||||
set_target_properties(${THIS} PROPERTIES
|
||||
LINKER_LANGUAGE CXX
|
||||
CXX_STANDARD 11
|
||||
CXX_STANDARD_REQUIRED ON)
|
||||
|
||||
endfunction()
|
||||
113
engine/libs/flecs/cmake/target_default_compile_warnings.cmake
Normal file
113
engine/libs/flecs/cmake/target_default_compile_warnings.cmake
Normal file
@@ -0,0 +1,113 @@
|
||||
function(target_default_compile_warnings_c THIS)
|
||||
|
||||
if (FLECS_STRICT)
|
||||
|
||||
if (CMAKE_C_COMPILER_ID STREQUAL "Clang"
|
||||
OR CMAKE_C_COMPILER_ID STREQUAL "AppleClang")
|
||||
|
||||
target_compile_options(${THIS} PRIVATE
|
||||
$<$<CONFIG:Debug>:-Wshadow>
|
||||
$<$<CONFIG:Debug>:-Wunused>
|
||||
-Wall -Wextra -Werror
|
||||
-Wcast-align
|
||||
-Wpedantic
|
||||
-Wconversion
|
||||
-Wsign-conversion
|
||||
-Wdouble-promotion
|
||||
-Wno-missing-prototypes
|
||||
-Wno-missing-variable-declarations)
|
||||
|
||||
elseif (CMAKE_C_COMPILER_ID STREQUAL "GNU")
|
||||
|
||||
target_compile_options(${THIS} PRIVATE
|
||||
$<$<CONFIG:Debug>:-Wshadow>
|
||||
$<$<CONFIG:Debug>:-Wunused>
|
||||
-Wall -Wextra -Werror
|
||||
-Wcast-align
|
||||
-Wpedantic
|
||||
-Wconversion
|
||||
-Wsign-conversion
|
||||
-Wdouble-promotion
|
||||
-Wno-missing-prototypes
|
||||
-Wno-missing-variable-declarations)
|
||||
|
||||
elseif (CMAKE_C_COMPILER_ID STREQUAL "MSVC")
|
||||
|
||||
target_compile_options(${THIS} PRIVATE
|
||||
/W3 /WX
|
||||
/w14242 /w14254 /w14263
|
||||
/w14265 /w14287 /we4289
|
||||
/w14296 /w14311 /w14545
|
||||
/w14546 /w14547 /w14549
|
||||
/w14555 /w14619 /w14640
|
||||
/w14826 /w14905 /w14906
|
||||
/w14928)
|
||||
|
||||
else ()
|
||||
|
||||
message(WARNING
|
||||
"No warning settings available for ${CMAKE_C_COMPILER_ID}. ")
|
||||
|
||||
endif ()
|
||||
|
||||
endif ()
|
||||
|
||||
endfunction()
|
||||
|
||||
function(target_default_compile_warnings_cxx THIS)
|
||||
|
||||
if (CMAKE_CXX_COMPILER_ID STREQUAL "Clang"
|
||||
OR CMAKE_CXX_COMPILER_ID STREQUAL "AppleClang")
|
||||
|
||||
target_compile_options(${THIS} PRIVATE
|
||||
#$<$<CONFIG:RELEASE>:-Werror>
|
||||
$<$<CONFIG:Debug>:-Wshadow>
|
||||
$<$<CONFIG:Debug>:-Wunused>
|
||||
-Wall -Wextra
|
||||
-Wnon-virtual-dtor
|
||||
-Wold-style-cast
|
||||
-Wcast-align
|
||||
-Woverloaded-virtual
|
||||
-Wpedantic
|
||||
-Wconversion
|
||||
-Wsign-conversion
|
||||
-Wdouble-promotion)
|
||||
|
||||
elseif (CMAKE_CXX_COMPILER_ID STREQUAL "GNU")
|
||||
|
||||
target_compile_options(${THIS} PRIVATE
|
||||
#$<$<CONFIG:RELEASE>:-Werror>
|
||||
$<$<CONFIG:Debug>:-Wshadow>
|
||||
$<$<CONFIG:Debug>:-Wunused>
|
||||
-Wall -Wextra
|
||||
-Wnon-virtual-dtor
|
||||
-Wold-style-cast
|
||||
-Wcast-align
|
||||
-Woverloaded-virtual
|
||||
-Wpedantic
|
||||
-Wconversion
|
||||
-Wsign-conversion
|
||||
-Wdouble-promotion)
|
||||
|
||||
elseif (CMAKE_CXX_COMPILER_ID STREQUAL "MSVC")
|
||||
|
||||
target_compile_options(${THIS} PRIVATE
|
||||
#$<$<CONFIG:RELEASE>:/WX>
|
||||
/W3
|
||||
/w14242 /w14254 /w14263
|
||||
/w14265 /w14287 /we4289
|
||||
/w14296 /w14311 /w14545
|
||||
/w14546 /w14547 /w14549
|
||||
/w14555 /w14619 /w14640
|
||||
/w14826 /w14905 /w14906
|
||||
/w14928)
|
||||
|
||||
else ()
|
||||
|
||||
message(WARNING
|
||||
"No Warnings specified for ${CMAKE_CXX_COMPILER_ID}. "
|
||||
"Consider using one of the following compilers: Clang, GNU, MSVC, AppleClang.")
|
||||
|
||||
endif ()
|
||||
|
||||
endfunction()
|
||||
Reference in New Issue
Block a user