move compile_commands.json to project root directory
This commit is contained in:
		
							
								
								
									
										2
									
								
								.gitignore
									
									
									
									
										vendored
									
									
								
							
							
						
						
									
										2
									
								
								.gitignore
									
									
									
									
										vendored
									
									
								
							@@ -18,6 +18,8 @@
 | 
			
		||||
build/
 | 
			
		||||
out/
 | 
			
		||||
 | 
			
		||||
compile_commands.json
 | 
			
		||||
 | 
			
		||||
# this is created when using Conan
 | 
			
		||||
CMakeUserPresets.json
 | 
			
		||||
 | 
			
		||||
 
 | 
			
		||||
@@ -16,7 +16,7 @@ if (NOT CMAKE_BUILD_TYPE)
 | 
			
		||||
endif ()
 | 
			
		||||
 | 
			
		||||
set(TOWNENGINE_TARGET townengine CACHE INTERNAL "")
 | 
			
		||||
set(TOWNENGINE_DIR ${CMAKE_CURRENT_SOURCE_DIR} CACHE INTERNAL "")
 | 
			
		||||
set(TOWNENGINE_ROOT_DIR ${CMAKE_CURRENT_SOURCE_DIR} CACHE INTERNAL "")
 | 
			
		||||
 | 
			
		||||
option(TOWNENGINE_HOT_RELOAD "Enable hot reloading support" TRUE)
 | 
			
		||||
add_compile_options($<$<BOOL:${TOWNENGINE_HOT_RELOAD}>:-fPIC>)
 | 
			
		||||
@@ -60,7 +60,7 @@ set(TOWNENGINE_SOURCE_FILES
 | 
			
		||||
 | 
			
		||||
        ${SYSTEM_SOURCE_FILES})
 | 
			
		||||
 | 
			
		||||
list(TRANSFORM TOWNENGINE_SOURCE_FILES PREPEND ${TOWNENGINE_DIR}/)
 | 
			
		||||
list(TRANSFORM TOWNENGINE_SOURCE_FILES PREPEND ${TOWNENGINE_ROOT_DIR}/)
 | 
			
		||||
 | 
			
		||||
# base engine code, reused for games and tools
 | 
			
		||||
if (TOWNENGINE_HOT_RELOAD)
 | 
			
		||||
@@ -68,7 +68,7 @@ if (TOWNENGINE_HOT_RELOAD)
 | 
			
		||||
else ()
 | 
			
		||||
        add_library(${TOWNENGINE_TARGET} STATIC ${TOWNENGINE_SOURCE_FILES})
 | 
			
		||||
endif ()
 | 
			
		||||
source_group(TREE ${TOWNENGINE_DIR} FILES ${TOWNENGINE_SOURCE_FILES})
 | 
			
		||||
source_group(TREE ${TOWNENGINE_ROOT_DIR} FILES ${TOWNENGINE_SOURCE_FILES})
 | 
			
		||||
 | 
			
		||||
set_target_properties(${TOWNENGINE_TARGET} PROPERTIES
 | 
			
		||||
                                           C_STANDARD 11
 | 
			
		||||
@@ -176,11 +176,11 @@ function(include_deps target)
 | 
			
		||||
                third-party/stb
 | 
			
		||||
                third-party/x-watcher)
 | 
			
		||||
 | 
			
		||||
        list(TRANSFORM THIRD_PARTY_INCLUDES PREPEND ${TOWNENGINE_DIR}/)
 | 
			
		||||
        list(TRANSFORM THIRD_PARTY_INCLUDES PREPEND ${TOWNENGINE_ROOT_DIR}/)
 | 
			
		||||
        target_include_directories(${target} SYSTEM PRIVATE ${THIRD_PARTY_INCLUDES})
 | 
			
		||||
 | 
			
		||||
        # allow access to headers from any point in source tree
 | 
			
		||||
        target_include_directories(${target} PRIVATE ${TOWNENGINE_DIR})
 | 
			
		||||
        target_include_directories(${target} PRIVATE ${TOWNENGINE_ROOT_DIR})
 | 
			
		||||
endfunction()
 | 
			
		||||
 | 
			
		||||
 | 
			
		||||
@@ -207,7 +207,7 @@ function(use_townengine target sources output_directory data_dir)
 | 
			
		||||
                target_link_libraries(${target}_game PUBLIC SDL2::SDL2)
 | 
			
		||||
 | 
			
		||||
                # launcher binary, loads game and engine shared library
 | 
			
		||||
                add_executable(${target}_app ${TOWNENGINE_DIR}/townengine/null.c)
 | 
			
		||||
                add_executable(${target}_app ${TOWNENGINE_ROOT_DIR}/townengine/null.c)
 | 
			
		||||
                set_target_properties(${target}_app PROPERTIES
 | 
			
		||||
                                                    OUTPUT_NAME launcher
 | 
			
		||||
                                                    LIBRARY_OUTPUT_DIRECTORY ${output_directory})
 | 
			
		||||
@@ -230,13 +230,13 @@ function(use_townengine target sources output_directory data_dir)
 | 
			
		||||
        link_deps(${target}_app)
 | 
			
		||||
        target_link_libraries(${target}_app PUBLIC ${TOWNENGINE_TARGET})
 | 
			
		||||
        set_target_properties(${target}_app PROPERTIES
 | 
			
		||||
                                        RUNTIME_OUTPUT_DIRECTORY ${output_directory})
 | 
			
		||||
                                            RUNTIME_OUTPUT_DIRECTORY ${output_directory})
 | 
			
		||||
 | 
			
		||||
        # copy dlls for baby windows
 | 
			
		||||
        add_custom_command(TARGET ${target}_app POST_BUILD
 | 
			
		||||
                COMMAND ${CMAKE_COMMAND} -E copy -t $<TARGET_FILE_DIR:${target}_app>
 | 
			
		||||
                                                    $<TARGET_RUNTIME_DLLS:${target}_app>
 | 
			
		||||
                COMMAND_EXPAND_LISTS)
 | 
			
		||||
                           COMMAND ${CMAKE_COMMAND} -E copy -t $<TARGET_FILE_DIR:${target}_app>
 | 
			
		||||
                                                               $<TARGET_RUNTIME_DLLS:${target}_app>
 | 
			
		||||
                           COMMAND_EXPAND_LISTS)
 | 
			
		||||
 | 
			
		||||
        if (UNIX)
 | 
			
		||||
                # create a bootstrapping script
 | 
			
		||||
@@ -261,6 +261,11 @@ if (${CMAKE_PROJECT_NAME} MATCHES townengine)
 | 
			
		||||
        add_subdirectory(apps/testgame)
 | 
			
		||||
endif ()
 | 
			
		||||
 | 
			
		||||
# move compie_commands.json into root directory so that it plays nicer with editors
 | 
			
		||||
add_custom_command(TARGET ${TOWNENGINE_TARGET} POST_BUILD
 | 
			
		||||
                   COMMAND ${CMAKE_COMMAND} -E copy_if_different ${CMAKE_BINARY_DIR}/compile_commands.json
 | 
			
		||||
                                                                 ${TOWNENGINE_ROOT_DIR})
 | 
			
		||||
 | 
			
		||||
# zip up assets
 | 
			
		||||
# currently, you must run cmake from the project root dir for this to work correctly
 | 
			
		||||
#file(ARCHIVE_CREATE OUTPUT ${CMAKE_CURRENT_BINARY_DIR}/data.${PACKAGE_EXTENSION}
 | 
			
		||||
 
 | 
			
		||||
		Reference in New Issue
	
	Block a user