mdecmake/cmake/MDEBase.cmake

75 lines
1.1 KiB
CMake
Raw Permalink Normal View History

2025-11-26 07:03:34 +09:00
include_guard(DIRECTORY)
2025-11-18 19:16:29 +09:00
include(GNUInstallDirs)
2025-12-17 19:24:52 +09:00
macro(mde_setup_base type name dir)
2025-11-18 19:16:29 +09:00
project(
${name}
)
file(
GLOB
${name}_SRC
*.c
)
2025-12-14 23:18:36 +09:00
if(${type} STREQUAL "project")
add_executable(
${name}
${${name}_SRC}
)
elseif(${type} STREQUAL "library")
add_library(
${name}
2025-12-17 22:55:22 +09:00
SHARED
2025-12-14 23:18:36 +09:00
${${name}_SRC}
)
endif()
2025-11-18 19:16:29 +09:00
2025-12-14 23:18:36 +09:00
if(NOT ${name} STREQUAL "MDECore")
target_link_libraries(
${name}
PRIVATE
MDECore
)
endif()
2025-11-18 19:16:29 +09:00
target_link_libraries(
${name}
PRIVATE
2025-12-14 23:18:36 +09:00
Mw
2025-11-18 19:16:29 +09:00
)
install(
TARGETS ${name}
DESTINATION ${dir}
)
endmacro()
2025-11-26 07:03:34 +09:00
2025-12-17 19:24:52 +09:00
macro(mde_setup_project name dir)
mde_setup_base(project ${name} ${dir})
2025-12-14 23:18:36 +09:00
endmacro()
2025-12-17 19:24:52 +09:00
macro(mde_setup_library name)
2025-12-17 22:55:22 +09:00
if(NOT ${ARGV1} STREQUAL "")
mde_setup_base(library ${name} ${ARGV1})
2025-12-14 23:20:29 +09:00
else()
2025-12-17 19:24:52 +09:00
mde_setup_base(library ${name} ${CMAKE_INSTALL_LIBDIR})
2025-12-14 23:20:29 +09:00
endif()
2025-12-14 23:18:36 +09:00
2025-12-28 22:11:43 +09:00
if(EXISTS "${CMAKE_CURRENT_SOURCE_DIR}/../include")
2025-12-14 23:18:36 +09:00
target_include_directories(
${name}
PUBLIC
../include
)
endif()
endmacro()
2025-12-17 19:24:52 +09:00
macro(mde_math_add name)
2025-11-26 07:03:34 +09:00
if(NOT CMAKE_SYSTEM_NAME STREQUAL "Windows")
target_link_libraries(
${name}
PRIVATE
m
)
endif()
endmacro()