mdecmake/cmake/MDEBase.cmake

74 lines
1 KiB
CMake
Raw 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}
${${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-14 23:20:29 +09:00
if(ARGV2)
2025-12-17 19:24:52 +09:00
mde_setup_base(library ${name} ARGV2)
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
if(EXISTS "../include")
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()