Skip to content

Commit

Permalink
Remove CMake target format
Browse files Browse the repository at this point in the history
Signed-off-by: yamacir-kit <[email protected]>
  • Loading branch information
yamacir-kit committed Oct 22, 2023
1 parent 8483f8b commit 8742f50
Show file tree
Hide file tree
Showing 6 changed files with 84 additions and 87 deletions.
115 changes: 57 additions & 58 deletions CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -5,10 +5,11 @@ execute_process(
COMMAND tr -d "\n"
OUTPUT_VARIABLE CURRENT_VERSION)

project(meevax DESCRIPTION "A programmable programming language"
HOMEPAGE_URL "https://github.com/yamacir-kit/meevax"
LANGUAGES CXX
VERSION ${CURRENT_VERSION})
project(meevax
DESCRIPTION "A programmable programming language"
HOMEPAGE_URL "https://github.com/yamacir-kit/meevax"
LANGUAGES CXX
VERSION ${CURRENT_VERSION})

include(GNUInstallDirs)

Expand All @@ -20,9 +21,9 @@ string(JOIN " " AGGRESSIVE_OPTIMIZATION_OPTIONS
)

set(CMAKE_CXX_EXTENSIONS OFF)
set(CMAKE_CXX_FLAGS_DEBUG "-Og -gdwarf-4") # NOTE: The `-gdwarf-4` option is set due to the following issues with Clang 14 and Valgrind versions below 3.20: https://bugzilla.mozilla.org/show_bug.cgi?id=1758782
set(CMAKE_CXX_FLAGS_MINSIZEREL "-Os -DNDEBUG")
set(CMAKE_CXX_FLAGS_RELEASE "-O2 -DNDEBUG ${AGGRESSIVE_OPTIMIZATION_OPTIONS}")
set(CMAKE_CXX_FLAGS_DEBUG "-Og -gdwarf-4") # NOTE: The `-gdwarf-4` option is set due to the following issues with Clang 14 and Valgrind versions below 3.20: https://bugzilla.mozilla.org/show_bug.cgi?id=1758782
set(CMAKE_CXX_FLAGS_MINSIZEREL "-Os -DNDEBUG")
set(CMAKE_CXX_FLAGS_RELEASE "-O2 -DNDEBUG ${AGGRESSIVE_OPTIMIZATION_OPTIONS}")
set(CMAKE_CXX_FLAGS_RELWITHDEBINFO "-O2 -gdwarf-4 -DNDEBUG")
set(CMAKE_CXX_FLAGS "-Wall -Wextra -Wpedantic -pipe")
set(CMAKE_CXX_STANDARD 17)
Expand Down Expand Up @@ -73,30 +74,23 @@ file(GLOB_RECURSE ${PROJECT_NAME}_KERNEL_SOURCES ${CMAKE_CURRENT_SOURCE_DIR}/src

target_sources(kernel PRIVATE ${${PROJECT_NAME}_KERNEL_SOURCES})

target_include_directories(kernel PUBLIC
$<BUILD_INTERFACE:${CMAKE_CURRENT_SOURCE_DIR}/include>
$<INSTALL_INTERFACE:${CMAKE_INSTALL_INCLUDEDIR}>)
target_include_directories(kernel
PUBLIC $<BUILD_INTERFACE:${CMAKE_CURRENT_SOURCE_DIR}/include>
PUBLIC $<INSTALL_INTERFACE:${CMAKE_INSTALL_INCLUDEDIR}>)

target_link_libraries(kernel PRIVATE ${CMAKE_DL_LIBS}
PUBLIC gmp)
target_link_libraries(kernel
PRIVATE ${CMAKE_DL_LIBS}
PUBLIC gmp)

set_target_properties(kernel PROPERTIES OUTPUT_NAME ${PROJECT_NAME} # Rename libkernel => libmeevax
VERSION ${PROJECT_VERSION}
SOVERSION ${PROJECT_VERSION_MAJOR}
LINK_FLAGS_RELEASE -s)

# ---- Target format -----------------------------------------------------------

add_executable(format)

target_sources(format PRIVATE ${CMAKE_CURRENT_SOURCE_DIR}/src/format.cpp)

target_link_libraries(format PRIVATE kernel)
set_target_properties(kernel PROPERTIES
OUTPUT_NAME ${PROJECT_NAME} # Rename libkernel => libmeevax
VERSION ${PROJECT_VERSION}
SOVERSION ${PROJECT_VERSION_MAJOR}
LINK_FLAGS_RELEASE -s)

# ---- Target basis ------------------------------------------------------------

add_custom_target(basis
DEPENDS format
COMMAND ${CMAKE_COMMAND} -P ${CMAKE_CURRENT_SOURCE_DIR}/configure/basis.cmake)

# ---- Target shell ------------------------------------------------------------
Expand All @@ -109,8 +103,9 @@ target_sources(shell PRIVATE ${CMAKE_CURRENT_SOURCE_DIR}/src/main.cpp)

target_link_libraries(shell PRIVATE kernel)

set_target_properties(shell PROPERTIES OUTPUT_NAME ${PROJECT_NAME} # Rename shell => meevax
LINK_FLAGS_RELEASE -s)
set_target_properties(shell PROPERTIES
OUTPUT_NAME ${PROJECT_NAME} # Rename shell => meevax
LINK_FLAGS_RELEASE -s)

# ---- CMake Package -----------------------------------------------------------

Expand All @@ -122,29 +117,30 @@ write_basic_package_version_file(

# ---- Target install ----------------------------------------------------------

# /usr/lib/libmeevax
install(TARGETS kernel
EXPORT ${PROJECT_NAME}-config
ARCHIVE DESTINATION ${CMAKE_INSTALL_LIBDIR}
LIBRARY DESTINATION ${CMAKE_INSTALL_LIBDIR})
install( # /usr/lib/libmeevax
TARGETS kernel
EXPORT ${PROJECT_NAME}-config
ARCHIVE DESTINATION ${CMAKE_INSTALL_LIBDIR}
LIBRARY DESTINATION ${CMAKE_INSTALL_LIBDIR})

# /usr/bin/meevax
install(TARGETS shell
RUNTIME DESTINATION ${CMAKE_INSTALL_BINDIR})
install( # /usr/bin/meevax
TARGETS shell
RUNTIME DESTINATION ${CMAKE_INSTALL_BINDIR})

# /usr/include/meevax
install(DIRECTORY ${CMAKE_CURRENT_SOURCE_DIR}/include/
DESTINATION ${CMAKE_INSTALL_INCLUDEDIR})
install( # /usr/include/meevax
DIRECTORY ${CMAKE_CURRENT_SOURCE_DIR}/include/
DESTINATION ${CMAKE_INSTALL_INCLUDEDIR})

# /usr/share/meevax/meevax-config.cmake
install(EXPORT ${PROJECT_NAME}-config
EXPORT_LINK_INTERFACE_LIBRARIES
DESTINATION ${CMAKE_INSTALL_DATADIR}/${PROJECT_NAME}
NAMESPACE Meevax::)
install( # /usr/share/meevax/meevax-config.cmake
EXPORT ${PROJECT_NAME}-config
EXPORT_LINK_INTERFACE_LIBRARIES
DESTINATION ${CMAKE_INSTALL_DATADIR}/${PROJECT_NAME}
NAMESPACE Meevax::)

# /usr/share/meevax/meevax-config-version.cmake
install(FILES ${CMAKE_CURRENT_BINARY_DIR}/${PROJECT_NAME}-config-version.cmake
DESTINATION ${CMAKE_INSTALL_DATADIR}/${PROJECT_NAME})
install(
FILES ${CMAKE_CURRENT_BINARY_DIR}/${PROJECT_NAME}-config-version.cmake
DESTINATION ${CMAKE_INSTALL_DATADIR}/${PROJECT_NAME})

# ---- Target package ----------------------------------------------------------

Expand All @@ -164,20 +160,22 @@ enable_testing()

find_program(${PROJECT_NAME}_MEMORY_CHECK_COMMAND valgrind)

set(${PROJECT_NAME}_MEMORY_CHECK_COMMAND_OPTIONS --error-exitcode=1 # = EXIT_FAILURE)
--leak-check=full
--quiet
--show-leak-kinds=all)
set(${PROJECT_NAME}_MEMORY_CHECK_OPTIONS
--error-exitcode=1 # = EXIT_FAILURE)
--leak-check=full
--quiet
--show-leak-kinds=all)

file(GLOB ${PROJECT_NAME}_TEST_SS ${CMAKE_CURRENT_SOURCE_DIR}/test/*.ss)

foreach(EACH IN LISTS ${PROJECT_NAME}_TEST_SS)
get_filename_component(FILENAME ${EACH} NAME_WE)
add_test(NAME ${FILENAME}
COMMAND ${${PROJECT_NAME}_MEMORY_CHECK_COMMAND}
${${PROJECT_NAME}_MEMORY_CHECK_COMMAND_OPTIONS}
${CMAKE_RUNTIME_OUTPUT_DIRECTORY}/meevax
${EACH})
add_test(
NAME ${FILENAME}
COMMAND ${${PROJECT_NAME}_MEMORY_CHECK_COMMAND}
${${PROJECT_NAME}_MEMORY_CHECK_OPTIONS}
${CMAKE_RUNTIME_OUTPUT_DIRECTORY}/meevax
${EACH})
endforeach()

file(GLOB ${PROJECT_NAME}_TEST_CPP ${CMAKE_CURRENT_SOURCE_DIR}/test/*.cpp)
Expand All @@ -187,10 +185,11 @@ foreach(EACH IN LISTS ${PROJECT_NAME}_TEST_CPP)
add_executable(assert-${FILENAME} ${EACH})
add_dependencies(assert-${FILENAME} basis)
target_link_libraries(assert-${FILENAME} PRIVATE kernel)
add_test(NAME assert-${FILENAME}
COMMAND ${${PROJECT_NAME}_MEMORY_CHECK_COMMAND}
${${PROJECT_NAME}_MEMORY_CHECK_COMMAND_OPTIONS}
${CMAKE_RUNTIME_OUTPUT_DIRECTORY}/assert-${FILENAME})
add_test(
NAME assert-${FILENAME}
COMMAND ${${PROJECT_NAME}_MEMORY_CHECK_COMMAND}
${${PROJECT_NAME}_MEMORY_CHECK_OPTIONS}
${CMAKE_RUNTIME_OUTPUT_DIRECTORY}/assert-${FILENAME})
endforeach()

# ---- Additional Targets ------------------------------------------------------
Expand Down
6 changes: 3 additions & 3 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -91,7 +91,7 @@ Procedures for each standard are provided by the following R7RS-style libraries:
cmake -B build -DCMAKE_BUILD_TYPE=Release
cd build
make package
sudo apt install build/meevax_0.5.59_amd64.deb
sudo apt install build/meevax_0.5.60_amd64.deb
```

or
Expand Down Expand Up @@ -123,9 +123,9 @@ sudo rm -rf /usr/local/share/meevax

| Target Name | Description
|-------------|-------------
| `all` | Build shared-library `libmeevax.0.5.59.so` and executable `meevax`
| `all` | Build shared-library `libmeevax.0.5.60.so` and executable `meevax`
| `test` | Test executable `meevax`
| `package` | Generate debian package `meevax_0.5.59_amd64.deb`
| `package` | Generate debian package `meevax_0.5.60_amd64.deb`
| `install` | Copy files into `/usr/local` directly

## Usage
Expand Down
2 changes: 1 addition & 1 deletion VERSION
Original file line number Diff line number Diff line change
@@ -1 +1 @@
0.5.59
0.5.60
Empty file removed basis/]
Empty file.
4 changes: 1 addition & 3 deletions configure/basis.cmake
Original file line number Diff line number Diff line change
Expand Up @@ -7,9 +7,7 @@ file(GLOB ${PROJECT_NAME}_BASIS_SOURCES ${TOPLEVEL}/basis/*.ss)

foreach(EACH IN LISTS ${PROJECT_NAME}_BASIS_SOURCES)
get_filename_component(FILENAME ${EACH} NAME)
execute_process(
COMMAND ${TOPLEVEL}/build/bin/format ${EACH}
OUTPUT_VARIABLE CONFIGURED_${FILENAME})
file(READ ${EACH} ${FILENAME})
endforeach()

configure_file(
Expand Down
44 changes: 22 additions & 22 deletions configure/basis.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -32,28 +32,28 @@ inline namespace kernel
constexpr auto basis()
{
return make_array(
R"##(${CONFIGURED_meevax.ss})##",
R"##(${CONFIGURED_r4rs.ss})##",
R"##(${CONFIGURED_r5rs.ss})##",
R"##(${CONFIGURED_r7rs.ss})##",
R"##(${CONFIGURED_srfi-0.ss})##",
R"##(${CONFIGURED_srfi-1.ss})##",
R"##(${CONFIGURED_srfi-4.ss})##",
R"##(${CONFIGURED_srfi-6.ss})##",
R"##(${CONFIGURED_srfi-8.ss})##",
R"##(${CONFIGURED_srfi-9.ss})##",
R"##(${CONFIGURED_srfi-11.ss})##",
R"##(${CONFIGURED_srfi-16.ss})##",
R"##(${CONFIGURED_srfi-23.ss})##",
R"##(${CONFIGURED_srfi-31.ss})##",
R"##(${CONFIGURED_srfi-34.ss})##",
R"##(${CONFIGURED_srfi-38.ss})##",
R"##(${CONFIGURED_srfi-39.ss})##",
R"##(${CONFIGURED_srfi-45.ss})##",
R"##(${CONFIGURED_srfi-78.ss})##",
R"##(${CONFIGURED_srfi-98.ss})##",
R"##(${CONFIGURED_srfi-111.ss})##",
R"##(${CONFIGURED_srfi-149.ss})##");
R"##(${meevax.ss})##",
R"##(${r4rs.ss})##",
R"##(${r5rs.ss})##",
R"##(${r7rs.ss})##",
R"##(${srfi-0.ss})##",
R"##(${srfi-1.ss})##",
R"##(${srfi-4.ss})##",
R"##(${srfi-6.ss})##",
R"##(${srfi-8.ss})##",
R"##(${srfi-9.ss})##",
R"##(${srfi-11.ss})##",
R"##(${srfi-16.ss})##",
R"##(${srfi-23.ss})##",
R"##(${srfi-31.ss})##",
R"##(${srfi-34.ss})##",
R"##(${srfi-38.ss})##",
R"##(${srfi-39.ss})##",
R"##(${srfi-45.ss})##",
R"##(${srfi-78.ss})##",
R"##(${srfi-98.ss})##",
R"##(${srfi-111.ss})##",
R"##(${srfi-149.ss})##");
}
} // namespace kernel
} // namespace meevax
Expand Down

0 comments on commit 8742f50

Please sign in to comment.