commit 326097e5d1b92a720e6eff163d4ebb8842c75dff
parent bf58c92ba9705dccc95008115e38604f16018941
Author: Benjamin Piaud <benjamin.piaud@meso-star.com>
Date: Tue, 2 Aug 2022 18:08:38 +0200
Replace Makefile by cmake
Diffstat:
| D | Makefile | | | 32 | -------------------------------- |
| A | cmake/CMakeLists.txt | | | 89 | +++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++ |
2 files changed, 89 insertions(+), 32 deletions(-)
diff --git a/Makefile b/Makefile
@@ -1,32 +0,0 @@
-.SUFFIXES: # Clean up default inference rules
-
-CC = cc
-INC = local/include
-LIB = local/lib
-WFLAGS = -Wall -Wextra -Wmissing-declarations -Wmissing-prototypes -Wconversion -Wshadow
-#CFLAGS = -O2 -std=c89 -pedantic -I.. -I$(INC) $(WFLAGS)
-CFLAGS = -g -std=c89 -pedantic -I$(INC) $(WFLAGS)
-LDFLAGS = -L$(LIB)
-#LDLIBS = -lgmsh -lscad -lrsys -lm
-LDLIBS = -lgmsh -lscad-dbg -lrsys -lm
-
-CG: src/main.o src/polygon.o src/city.o src/building.o src/ground.o
- $(CC) -o $@ $(LDLIBS) $(LDFLAGS) $^
-
-src/main.o: src/main.c
- $(CC) $(CFLAGS) -c $< -o $@
-
-src/city.o: src/city.c
- $(CC) $(CFLAGS) -c $< -o $@
-
-src/ground.o: src/ground.c
- $(CC) $(CFLAGS) -c $< -o $@
-
-src/building.o: src/building.c
- $(CC) $(CFLAGS) -c $< -o $@
-
-src/polygon.o: src/polygon.c src/polygon.h
- $(CC) $(CFLAGS) -c $< -o $@
-
-clean:
- @rm -f src/*.o CG
diff --git a/cmake/CMakeLists.txt b/cmake/CMakeLists.txt
@@ -0,0 +1,89 @@
+# Copyright (C) 2022 |Meso|Star> (contact@meso-star.com)
+#
+# This program is free software: you can redistribute it and/or modify
+# it under the terms of the GNU General Public License as published by
+# the Free Software Foundation, either version 3 of the License, or
+# (at your option) any later version.
+#
+# This program is distributed in the hope that it will be useful,
+# but WITHOUT ANY WARRANTY; without even the implied warranty of
+# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+# GNU General Public License for more details.
+#
+# You should have received a copy of the GNU General Public License
+# along with this program. If not, see <http://www.gnu.org/licenses/>.
+
+cmake_minimum_required(VERSION 3.1)
+project(city_generator2 C)
+enable_testing()
+
+set(CG2_SOURCE_DIR ${PROJECT_SOURCE_DIR}/../src)
+option(NO_TEST "Disable the test" OFF)
+
+################################################################################
+# Check dependencies
+################################################################################
+find_package(RCMake 0.4.1 REQUIRED)
+find_package(RSys 0.12.1 REQUIRED)
+find_package(StarCAD 0.1 REQUIRED)
+
+set(CMAKE_MODULE_PATH ${CMAKE_MODULE_PATH} ${RCMAKE_SOURCE_DIR})
+include(rcmake)
+include(rcmake_runtime)
+
+include_directories(${SCAD_INCLUDE_DIR} ${RSys_INCLUDE_DIR})
+
+if(CMAKE_COMPILER_IS_GNUCC)
+ set(CMAKE_C_FLAGS "${CMAKE_C_FLAGS} -std=c89")
+endif()
+
+################################################################################
+# Configure and define targets
+################################################################################
+set(VERSION_MAJOR 0)
+set(VERSION_MINOR 1)
+set(VERSION_PATCH 0)
+set(VERSION ${VERSION_MAJOR}.${VERSION_MINOR}.${VERSION_PATCH})
+
+set(CG2_FILES_SRC
+ main.c
+ city.c
+ building.c
+ ground.c
+ polygon.c)
+
+set(CG2_FILES_INC
+ city.h
+ building.h
+ ground.h
+ polygon.h)
+
+set(CG2_FILES_DOC COPYING README.md)
+
+# Prepend each file in the `CG2_FILES_<SRC|INC>' list by `CG2_SOURCE_DIR'
+rcmake_prepend_path(CG2_FILES_SRC ${CG2_SOURCE_DIR})
+rcmake_prepend_path(CG2_FILES_INC ${CG2_SOURCE_DIR})
+rcmake_prepend_path(CG2_FILES_DOC ${PROJECT_SOURCE_DIR}/../)
+
+if(CMAKE_COMPILER_IS_GNUCC)
+ set(MATH_LIB m)
+endif()
+
+add_executable(city_generator2
+ ${CG2_FILES_SRC}
+ ${CG2_FILES_INC})
+
+target_link_libraries(city_generator2 RSys StarCAD ${MATH_LIB})
+
+set_target_properties(city_generator2 PROPERTIES
+ VERSION ${VERSION})
+
+################################################################################
+# Define output & install directories
+################################################################################
+install(TARGETS city_generator2
+ ARCHIVE DESTINATION bin
+ LIBRARY DESTINATION lib
+ RUNTIME DESTINATION bin)
+install(FILES ${CG2_FILES_DOC} DESTINATION share/doc/city_generator2)
+