parent
e725b10a9f
commit
285614e4c2
@ -1,44 +0,0 @@
|
||||
# This file was generated automatically by cmkr.
|
||||
|
||||
cmake_minimum_required(VERSION 3.15)
|
||||
|
||||
# Regenerate CMakeLists.txt automatically in the root project
|
||||
set(CMKR_ROOT_PROJECT OFF)
|
||||
if(CMAKE_CURRENT_SOURCE_DIR STREQUAL CMAKE_SOURCE_DIR)
|
||||
set(CMKR_ROOT_PROJECT ON)
|
||||
|
||||
# Bootstrap cmkr
|
||||
include(cmkr.cmake OPTIONAL RESULT_VARIABLE CMKR_INCLUDE_RESULT)
|
||||
if(CMKR_INCLUDE_RESULT)
|
||||
cmkr()
|
||||
endif()
|
||||
|
||||
# Enable folder support
|
||||
set_property(GLOBAL PROPERTY USE_FOLDERS ON)
|
||||
endif()
|
||||
|
||||
# Create a configure-time dependency on cmake.toml to improve IDE support
|
||||
if(CMKR_ROOT_PROJECT)
|
||||
configure_file(cmake.toml cmake.toml COPYONLY)
|
||||
endif()
|
||||
|
||||
project(example
|
||||
VERSION
|
||||
0.1.0
|
||||
)
|
||||
|
||||
# Target example
|
||||
set(example_SOURCES
|
||||
"src/example.cpp"
|
||||
cmake.toml
|
||||
)
|
||||
|
||||
add_executable(example ${example_SOURCES})
|
||||
|
||||
get_directory_property(CMKR_VS_STARTUP_PROJECT DIRECTORY ${PROJECT_SOURCE_DIR} DEFINITION VS_STARTUP_PROJECT)
|
||||
if(NOT CMKR_VS_STARTUP_PROJECT)
|
||||
set_property(DIRECTORY ${PROJECT_SOURCE_DIR} PROPERTY VS_STARTUP_PROJECT example)
|
||||
endif()
|
||||
|
||||
source_group(TREE ${CMAKE_CURRENT_SOURCE_DIR} FILES ${example_SOURCES})
|
||||
|
@ -1,12 +0,0 @@
|
||||
# This is a minimal example project used for testing the cmkr bootstrapping process
|
||||
|
||||
[cmake]
|
||||
version = "3.15"
|
||||
|
||||
[project]
|
||||
name = "example"
|
||||
version = "0.1.0"
|
||||
|
||||
[target.example]
|
||||
type = "executable"
|
||||
sources = ["src/example.cpp"]
|
@ -0,0 +1,21 @@
|
||||
# Enumerates the target sources and automatically generates include/resources/${RESOURCE_NAME}.h from all .cmake files
|
||||
function(generate_resources target)
|
||||
get_property(TARGET_SOURCES
|
||||
TARGET ${target}
|
||||
PROPERTY SOURCES
|
||||
)
|
||||
foreach(SOURCE ${TARGET_SOURCES})
|
||||
if(SOURCE MATCHES ".cmake$")
|
||||
get_filename_component(RESOURCE_NAME "${SOURCE}" NAME_WE)
|
||||
set(RESOURCE_HEADER "include/resources/${RESOURCE_NAME}.h")
|
||||
configure_file("${SOURCE}" "${CMAKE_CURRENT_BINARY_DIR}/${RESOURCE_HEADER}")
|
||||
file(READ "${CMAKE_CURRENT_BINARY_DIR}/${RESOURCE_HEADER}" RESOURCE_CONTENTS)
|
||||
file(GENERATE
|
||||
OUTPUT "${CMAKE_CURRENT_BINARY_DIR}/${RESOURCE_HEADER}"
|
||||
CONTENT "namespace cmkr {\nnamespace resources {\nstatic const char* ${RESOURCE_NAME} = R\"RESOURCE(${RESOURCE_CONTENTS})RESOURCE\";\n}\n}"
|
||||
)
|
||||
message(STATUS "[cmkr] Generated ${RESOURCE_HEADER}")
|
||||
endif()
|
||||
endforeach()
|
||||
target_include_directories(${target} PUBLIC "${CMAKE_CURRENT_BINARY_DIR}/include")
|
||||
endfunction()
|
@ -0,0 +1,27 @@
|
||||
cmake_minimum_required(VERSION 3.20)
|
||||
|
||||
find_package(Git REQUIRED)
|
||||
|
||||
execute_process(COMMAND
|
||||
"${GIT_EXECUTABLE}" name-rev --tags --name-only HEAD
|
||||
OUTPUT_VARIABLE GIT_TAG
|
||||
)
|
||||
|
||||
string(FIND "${GIT_TAG}" "\n" NEWLINE_POS)
|
||||
string(SUBSTRING "${GIT_TAG}" 0 ${NEWLINE_POS} GIT_TAG)
|
||||
string(STRIP "${GIT_TAG}" GIT_TAG)
|
||||
|
||||
if("${GIT_TAG}" STREQUAL "")
|
||||
message(FATAL_ERROR "Failed to retrieve git tag!")
|
||||
endif()
|
||||
|
||||
message(STATUS "CMKR_TAG: '${GIT_TAG}'")
|
||||
|
||||
file(READ "cmake/cmkr.cmake" CMKR_CMAKE)
|
||||
string(REGEX REPLACE "CMKR_TAG \"[^\"]+\"" "CMKR_TAG \"${GIT_TAG}\"" CMKR_CMAKE "${CMKR_CMAKE}")
|
||||
file(CONFIGURE
|
||||
OUTPUT "cmake/cmkr.cmake"
|
||||
CONTENT "${CMKR_CMAKE}"
|
||||
@ONLY
|
||||
NEWLINE_STYLE LF
|
||||
)
|
@ -1,6 +0,0 @@
|
||||
#include <cstdio>
|
||||
|
||||
int main()
|
||||
{
|
||||
puts("Hello from cmkr!");
|
||||
}
|
@ -1,2 +1,3 @@
|
||||
# These will be generated by cmkr, so no point in tracking them
|
||||
**/CMakeLists.txt
|
||||
**/cmkr.cmake
|
Loading…
Reference in new issue