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)
endif()
if ("${CMAKE_GENERATOR}" STREQUAL "Ninja")
set(NINJA 1)
endif()
if ("${CMAKE_SYSTEM_NAME}" STREQUAL "Darwin")
set(OSX 1)
endif()
@ -161,17 +165,6 @@ set(CMAKE_C_FLAGS_DEBUG "${CMAKE_C_FLAGS_DEBUG} -DDEBUG")
if (STEAM)
set(CMAKE_C_FLAGS_DEBUG "${CMAKE_C_FLAGS_DEBUG} -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
src/steam/steamworks_api_wrapper
)
@ -179,6 +172,18 @@ else ()
set(STEAM_SOURCES "")
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:
add_executable(breakhack
src/main

View File

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