diff options
author | IronClawTrem <louie.nutman@gmail.com> | 2020-02-16 03:40:06 +0000 |
---|---|---|
committer | IronClawTrem <louie.nutman@gmail.com> | 2020-02-16 03:40:06 +0000 |
commit | 425decdf7e9284d15aa726e3ae96b9942fb0e3ea (patch) | |
tree | 6c0dd7edfefff1be7b9e75fe0b3a0a85fe1595f3 /cmake | |
parent | ccb0b2e4d6674a7a00c9bf491f08fc73b6898c54 (diff) |
create tremded branch
Diffstat (limited to 'cmake')
-rw-r--r-- | cmake/AddQVM.cmake | 73 | ||||
-rw-r--r-- | cmake/SDL2.cmake | 13 | ||||
-rw-r--r-- | cmake/build_dir | 17 | ||||
-rw-r--r-- | cmake/debug_cflags | 4 |
4 files changed, 107 insertions, 0 deletions
diff --git a/cmake/AddQVM.cmake b/cmake/AddQVM.cmake new file mode 100644 index 0000000..84de0c7 --- /dev/null +++ b/cmake/AddQVM.cmake @@ -0,0 +1,73 @@ + +include(CMakeParseArguments) + +set(QVM_TOOLS_DIR ${CMAKE_RUNTIME_OUTPUT_DIRECTORY}/qvm_tools) +set(Q3CPP_BINARY ${QVM_TOOLS_DIR}/q3cpp ) +set(Q3RCC_BINARY ${QVM_TOOLS_DIR}/q3rcc ) +set(Q3LCC_BINARY ${QVM_TOOLS_DIR}/q3lcc ) +set(Q3ASM_BINARY ${QVM_TOOLS_DIR}/q3asm ) + +set(QVM_DEPS ${Q3ASM_BINARY} ${Q3CPP_BINARY} ${Q3LCC_BINARY} ${Q3RCC_BINARY}) + +macro(QVM_COMPILE_ASM defs outfile infile) + add_custom_command( + OUTPUT ${outfile} + COMMAND ${Q3LCC_BINARY} + ARGS ${ADD_QVM_D} -o ${outfile} ${infile} + DEPENDS ${QVM_DEPS} + ) + set_source_files_properties(${outfile} PROPERTIES GENERATED TRUE) +endmacro() + +macro(ADD_QVM Name) + cmake_parse_arguments(ADD_QVM "" "" "" ${ARGN}) + + #message( "QVM: ${Name}" ) + + string(TOUPPER ${Name} UPNAME) + set(defs "-DVMS -D${UPNAME}") + + #message( "DEFINITIONS ${defs}" ) + + foreach(srcfile ${ADD_QVM_UNPARSED_ARGUMENTS}) + #message( "> ${srcfile}" ) + + get_filename_component(ext ${srcfile} EXT) + if ("${ext}" STREQUAL ".asm") + set(outfile ${CMAKE_CURRENT_SOURCE_DIR}/${srcfile}) + # Add asm files directly + list(APPEND srcs ${outfile}) + endif() + + if ("${ext}" STREQUAL ".c") + get_filename_component(outfile ${srcfile} NAME_WE) + set(outfile ${outfile}.asm) + # compile C code into asm + qvm_compile_asm(${defs} ${outfile} ${CMAKE_CURRENT_SOURCE_DIR}/${srcfile}) + # add asm to list + list(APPEND srcs ${outfile}) + endif() + + if ("${ext}" STREQUAL ".h") + # XXX: Ignore headers?? + endif() + endforeach() + + #message("SOURCES <${srcs}>") + + add_custom_command( + OUTPUT ${CMAKE_CURRENT_BINARY_DIR}/${Name}.qvm + COMMAND ${Q3ASM_BINARY} + ARGS -o ${Name}.qvm ${srcs} + DEPENDS ${Q3ASM_BINARY} ${srcs} + ) + add_custom_target(${Name}.qvm DEPENDS ${CMAKE_CURRENT_BINARY_DIR}/${Name}.qvm) +endmacro() +# +#============================================================ + +include(FindPackageHandleStandardArgs) + +find_package_handle_standard_args(QVM + REQUIRED_VARS Q3LCC_BINARY Q3ASM_BINARY + ) diff --git a/cmake/SDL2.cmake b/cmake/SDL2.cmake new file mode 100644 index 0000000..a18a3a5 --- /dev/null +++ b/cmake/SDL2.cmake @@ -0,0 +1,13 @@ +if(USE_INTERNAL_SDL2) + set(SDL2_DEFINES "-DUSE_LOCAL_HEADERS=1") + set(SDL2_PREFIX "${CMAKE_SOURCE_DIR}/external/SDL2") + set(SDL2_INCLUDE_DIRS "${SDL2_PREFIX}/include") + set(SDL2_LIBRARIES "-L${SDL2_PREFIX}/libs/${CMAKE_SYSTEM_NAME} -lSDL2-2.0.0") +else(USE_INTERNAL_SDL2) + set(SDL2_PREFIX "/usr") + if(APPLE) + set(SDL2_PREFIX "/usr/local") + endif(APPLE) + set(SDL2_INCLUDE_DIRS "${SDL2_PREFIX}/include/SDL2") + set(SDL2_LIBRARIES "-L${SDL2_PREFIX} -lSDL2") +endif(USE_INTERNAL_SDL2) diff --git a/cmake/build_dir b/cmake/build_dir new file mode 100644 index 0000000..b86b288 --- /dev/null +++ b/cmake/build_dir @@ -0,0 +1,17 @@ +# vim:ft=cmake + +if (NOT CMAKE_BUILD_TYPE) + set(CMAKE_BUILD_TYPE Release) +endif() + +set(CMAKE_OSX_ARCHITECTURES ${CMAKE_SYSTEM_PROCESSOR}) + +string( TOLOWER "${CMAKE_BUILD_TYPE}-${CMAKE_SYSTEM_NAME}-${CMAKE_SYSTEM_PROCESSOR}" + BUILD_ASSETS_DIR) + +set(CMAKE_BINARY_DIR ${CMAKE_BINARY_DIR}/${BUILD_ASSETS_DIR}) +set(CMAKE_RUNTIME_OUTPUT_DIRECTORY ${CMAKE_BINARY_DIR}) +#set(CMAKE_ARCHIVE_OUTPUT_DIRECTORY ${CMAKE_BINARY_DIR}) +#set(CMAKE_LIBRARY_OUTPUT_DIRECTORY ${CMAKE_BINARY_DIR}/${BUILD_ASSETS_DIR}) +#set(CMAKE_RUNTIME_OUTPUT_DIRECTORY ${CMAKE_BINARY_DIR}/${BUILD_ASSETS_DIR}) + diff --git a/cmake/debug_cflags b/cmake/debug_cflags new file mode 100644 index 0000000..d383256 --- /dev/null +++ b/cmake/debug_cflags @@ -0,0 +1,4 @@ +# vim:ft=cmake +set(DEBUG_FLAGS "-O0 -g3 -fsanitize=address -fsanitize-blacklist=${CMAKE_SOURCE_DIR}/misc/blacklist.txt -fno-omit-frame-pointer") +set(CMAKE_C_FLAGS_DEBUG ${DEBUG_FLAGS}) +set(CMAKE_CXX_FLAGS_DEBUG ${DEBUG_FLAGS}) |