Make ninja builds smoother

This commit is contained in:
Linus Probert 2019-04-06 12:27:42 +02:00
parent c917981bad
commit c0a4a4eb93
2 changed files with 23 additions and 18 deletions

View File

@ -52,6 +52,10 @@ elseif ("${CMAKE_C_COMPILER_ID}" STREQUAL "GNU")
set(GCC 1) set(GCC 1)
endif() endif()
if ("${CMAKE_GENERATOR}" STREQUAL "Ninja")
set(NINJA 1)
endif()
if ("${CMAKE_SYSTEM_NAME}" STREQUAL "Darwin") if ("${CMAKE_SYSTEM_NAME}" STREQUAL "Darwin")
set(OSX 1) set(OSX 1)
endif() endif()
@ -161,17 +165,6 @@ set(CMAKE_C_FLAGS_DEBUG "${CMAKE_C_FLAGS_DEBUG} -DDEBUG")
if (STEAM) if (STEAM)
set(CMAKE_C_FLAGS_DEBUG "${CMAKE_C_FLAGS_DEBUG} -DSTEAM_BUILD") set(CMAKE_C_FLAGS_DEBUG "${CMAKE_C_FLAGS_DEBUG} -DSTEAM_BUILD")
set(CMAKE_C_FLAGS_RELEASE "${CMAKE_C_FLAGS_RELEASE} -DSTEAM_BUILD") set(CMAKE_C_FLAGS_RELEASE "${CMAKE_C_FLAGS_RELEASE} -DSTEAM_BUILD")
endif ()
if (MINGW)
set(CMAKE_C_FLAGS_RELEASE "${CMAKE_C_FLAGS_RELEASE} -DMINGW")
endif (MINGW)
if (NOT MSVC)
set(CMAKE_C_FLAGS_DEBUG "${CMAKE_C_FLAGS_DEBUG} -D__FNAME__='\"$(subst ${CMAKE_SOURCE_DIR}/,,$(abspath $<))\"'")
else (NOT MSVC)
set(CMAKE_C_FLAGS_DEBUG "${CMAKE_C_FLAGS_DEBUG} -D__FNAME__=__FILE__")
endif (NOT MSVC)
if (STEAM)
set(STEAM_SOURCES set(STEAM_SOURCES
src/steam/steamworks_api_wrapper src/steam/steamworks_api_wrapper
) )
@ -179,6 +172,18 @@ else ()
set(STEAM_SOURCES "") set(STEAM_SOURCES "")
endif () endif ()
if (MINGW)
set(CMAKE_C_FLAGS_RELEASE "${CMAKE_C_FLAGS_RELEASE} -DMINGW")
endif (MINGW)
if (NOT MSVC AND NOT NINJA)
set(CMAKE_C_FLAGS_DEBUG "${CMAKE_C_FLAGS_DEBUG} -D__FNAME__='\"$(subst ${CMAKE_SOURCE_DIR}/,,$(abspath $<))\"'")
elseif (NINJA)
set(CMAKE_C_FLAGS_DEBUG "${CMAKE_C_FLAGS_DEBUG} -D__FNAME__='\"$$(subst ${CMAKE_SOURCE_DIR}/,,$$(abspath $$<))\"'")
else ()
set(CMAKE_C_FLAGS_DEBUG "${CMAKE_C_FLAGS_DEBUG} -D__FNAME__=__FILE__")
endif ()
# PROGRAMS: # PROGRAMS:
add_executable(breakhack add_executable(breakhack
src/main src/main

View File

@ -1,18 +1,18 @@
all: all:
@make -sC _build/debug @ninja -C _build/debug
.PHONY: all .PHONY: all
release: release:
@make -sC _build/release @ninja -C _build/release
.PHONY: release .PHONY: release
clean: clean:
@make clean -sC _build/debug @ninja clean -C _build/debug
@make clean -sC _build/release @ninja clean -C _build/release
.PHONY: clean .PHONY: clean
test: test:
@make test -sC _build/debug @ninja test -C _build/debug
.PHONY: test .PHONY: test
run: $(all) run: $(all)
@ -24,9 +24,9 @@ playtest: $(all)
.PHONY: run .PHONY: run
lint: lint:
@make lint -sC _build/debug @ninja lint -C _build/debug
.PHONY: lint .PHONY: lint
package: package:
@make package -sC _build/release @ninja package -C _build/release
.PHONY: package .PHONY: package