Skip to content

Commit 5db5f1e

Browse files
committed
Add a CMake buildsystem.
Additionally, update build tools so that no stdio redirection is necessary.
1 parent c5364fe commit 5db5f1e

17 files changed

+511
-45
lines changed

.gitignore

Lines changed: 2 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,2 @@
1-
Makefile.in
2-
/ac-aux/
3-
/aclocal.m4
4-
/autom4te.cache/
5-
/config.h.in
6-
/config.h.in~
7-
/configure
8-
/m4/
1+
/CMakeCache.txt
2+
/cbuild/

CMakeLists.txt

Lines changed: 82 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,82 @@
1+
# cmake configuration
2+
3+
cmake_minimum_required(VERSION 2.8.12)
4+
cmake_policy(VERSION 2.8.12)
5+
set(CMAKE_MODULE_PATH ${CMAKE_MODULE_PATH}
6+
"${CMAKE_SOURCE_DIR}/cmake/")
7+
8+
include(CheckIncludeFile)
9+
10+
# for /MT on MSVC
11+
set(CMAKE_USER_MAKE_RULES_OVERRIDE
12+
"${CMAKE_SOURCE_DIR}/cmake/c_flag_overrides.cmake")
13+
set(CMAKE_USER_MAKE_RULES_OVERRIDE_CXX
14+
"${CMAKE_SOURCE_DIR}/cmake/cxx_flag_overrides.cmake")
15+
16+
# project
17+
18+
project(solvespace)
19+
set(solvespace_VERSION_MAJOR 2)
20+
set(solvespace_VERSION_MINOR 1)
21+
22+
# compiler
23+
24+
if(WIN32)
25+
add_definitions(
26+
-D_CRT_SECURE_NO_DEPRECATE=1
27+
-D_CRT_SECURE_NO_WARNINGS=1
28+
-D_WIN32_WINNT=0x500
29+
-D_WIN32_IE=_WIN32_WINNT
30+
-DISOLATION_AWARE_ENABLED=1
31+
-DWIN32=1
32+
-DWIN32_LEAN_AND_MEAN=1)
33+
endif()
34+
35+
# dependencies
36+
37+
CHECK_INCLUDE_FILE("stdint.h" HAVE_STDINT_H)
38+
39+
find_package(OpenGL REQUIRED)
40+
41+
find_package(Perl)
42+
find_package(PerlModules COMPONENTS GD)
43+
if(NOT (PERL_FOUND AND PERLMODULES_FOUND))
44+
message(STATUS "Perl with GD not found; icons will not be regenerated if modified")
45+
endif()
46+
47+
if(WIN32)
48+
find_package(PNG)
49+
50+
if(NOT PNG_FOUND)
51+
message(STATUS "Using prebuilt libpng")
52+
53+
set(PNG_FOUND TRUE)
54+
set(PNG_LIBRARIES
55+
"${CMAKE_SOURCE_DIR}/extlib/libpng/libpng.lib"
56+
"${CMAKE_SOURCE_DIR}/extlib/zlib/zlib.lib")
57+
set(PNG_INCLUDE_DIRS
58+
"${CMAKE_SOURCE_DIR}/extlib/libpng")
59+
endif()
60+
61+
message(STATUS "Using prebuilt SpaceWare")
62+
set(SPACEWARE_FOUND TRUE)
63+
set(SPACEWARE_INCLUDE_DIR
64+
"${CMAKE_SOURCE_DIR}/extlib/si")
65+
set(SPACEWARE_LIBRARIES
66+
"${CMAKE_SOURCE_DIR}/extlib/si/siapp.lib")
67+
else()
68+
find_package(PNG REQUIRED)
69+
find_package(SpaceWare)
70+
71+
find_package(FLTK REQUIRED)
72+
CHECK_INCLUDE_FILE("fontconfig/fontconfig.h" HAVE_FONTCONFIG)
73+
endif()
74+
75+
# components
76+
77+
if(WIN32)
78+
add_subdirectory(tools)
79+
endif()
80+
81+
add_subdirectory(src)
82+
add_subdirectory(exposed)

cmake/FindPerlModules.cmake

Lines changed: 77 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,77 @@
1+
# - try to find perl modules, passed as COMPONENTS
2+
#
3+
# Non-cache variable you might use in your CMakeLists.txt:
4+
# PERLMODULES_FOUND
5+
#
6+
# Requires these CMake modules:
7+
# FindPackageHandleStandardArgs (known included with CMake >=2.6.2)
8+
#
9+
# Original Author:
10+
# 2012 Ryan Pavlik <rpavlik@iastate.edu> <abiryan@ryand.net>
11+
# http://academic.cleardefinition.com
12+
# Iowa State University HCI Graduate Program/VRAC
13+
#
14+
# Copyright Iowa State University 2012.
15+
# Distributed under the Boost Software License, Version 1.0.
16+
# (See accompanying file LICENSE_1_0.txt or copy at
17+
# http://www.boost.org/LICENSE_1_0.txt)
18+
19+
if(NOT PERL_FOUND)
20+
find_package(Perl QUIET)
21+
endif()
22+
23+
set(_deps_check)
24+
if(PERL_FOUND)
25+
foreach(module ${PerlModules_FIND_COMPONENTS})
26+
string(REPLACE "::" "/" modfilename "${module}.pm")
27+
string(REPLACE "::" "_" modvarname "PERLMODULES_${module}_MODULE")
28+
string(TOUPPER "${modvarname}" modvarname)
29+
list(APPEND _deps_check ${modvarname})
30+
if(NOT ${modvarname})
31+
if(NOT PerlModules_FIND_QUIETLY)
32+
message(STATUS "Checking for perl module ${module}")
33+
endif()
34+
execute_process(COMMAND
35+
"${PERL_EXECUTABLE}"
36+
"-e"
37+
"use ${module}; print \$INC{\"${modfilename}\"}"
38+
RESULT_VARIABLE result_code
39+
OUTPUT_VARIABLE filename
40+
ERROR_VARIABLE error_info
41+
OUTPUT_STRIP_TRAILING_WHITESPACE)
42+
if(result_code EQUAL 0)
43+
if(NOT PerlModules_FIND_QUIETLY)
44+
message(STATUS
45+
"Checking for perl module ${module} - found at ${filename}")
46+
endif()
47+
set(${modvarname}
48+
"${filename}"
49+
CACHE
50+
FILEPATH
51+
"Location found for module ${module}"
52+
FORCE)
53+
mark_as_advanced(${modvarname})
54+
else()
55+
if(NOT PerlModules_FIND_QUIETLY)
56+
message(STATUS "Checking for perl module ${module} - failed")
57+
endif()
58+
set(${modvarname}
59+
"NOTFOUND"
60+
CACHE
61+
FILEPATH
62+
"No location found for module ${module}"
63+
FORCE)
64+
file(APPEND
65+
${CMAKE_BINARY_DIR}${CMAKE_FILES_DIRECTORY}/CMakeError.log
66+
"Determining if the Perl module ${module} exists failed with the following error output:\n"
67+
"${error_info}\n\n")
68+
endif()
69+
endif()
70+
endforeach()
71+
endif()
72+
73+
include(FindPackageHandleStandardArgs)
74+
find_package_handle_standard_args(PerlModules
75+
DEFAULT_MSG
76+
PERL_FOUND
77+
${_deps_check})

cmake/FindSpaceWare.cmake

Lines changed: 28 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,28 @@
1+
# Find the libspnav library and header.
2+
#
3+
# Sets the usual variables expected for find_package scripts:
4+
#
5+
# SPACEWARE_INCLUDE_DIR - header location
6+
# SPACEWARE_LIBRARIES - library to link against
7+
# SPACEWARE_FOUND - true if pugixml was found.
8+
9+
if(UNIX)
10+
11+
find_path(SPACEWARE_INCLUDE_DIR
12+
spnav.h)
13+
14+
find_library(SPACEWARE_LIBRARY
15+
NAMES spnav libspnav)
16+
17+
# Support the REQUIRED and QUIET arguments, and set SPACEWARE_FOUND if found.
18+
include(FindPackageHandleStandardArgs)
19+
FIND_PACKAGE_HANDLE_STANDARD_ARGS(SPACEWARE DEFAULT_MSG
20+
SPACEWARE_LIBRARY SPACEWARE_INCLUDE_DIR)
21+
22+
if(SPACEWARE_FOUND)
23+
set(SPACEWARE_LIBRARIES ${SPACEWARE_LIBRARY})
24+
endif()
25+
26+
mark_as_advanced(SPACEWARE_LIBRARY SPACEWARE_INCLUDE_DIR)
27+
28+
endif()

cmake/c_flag_overrides.cmake

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,6 @@
1+
if(MSVC)
2+
set(CMAKE_C_FLAGS_DEBUG_INIT "/D_DEBUG /MTd /Zi /Ob0 /Od /RTC1")
3+
set(CMAKE_C_FLAGS_MINSIZEREL_INIT "/MT /O1 /Ob1 /D NDEBUG")
4+
set(CMAKE_C_FLAGS_RELEASE_INIT "/MT /O2 /Ob2 /D NDEBUG")
5+
set(CMAKE_C_FLAGS_RELWITHDEBINFO_INIT "/MT /Zi /O2 /Ob1 /D NDEBUG")
6+
endif()

cmake/cxx_flag_overrides.cmake

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,6 @@
1+
if(MSVC)
2+
set(CMAKE_CXX_FLAGS_DEBUG_INIT "/D_DEBUG /MTd /Zi /Ob0 /Od /RTC1")
3+
set(CMAKE_CXX_FLAGS_MINSIZEREL_INIT "/MT /O1 /Ob1 /D NDEBUG")
4+
set(CMAKE_CXX_FLAGS_RELEASE_INIT "/MT /O2 /Ob2 /D NDEBUG")
5+
set(CMAKE_CXX_FLAGS_RELWITHDEBINFO_INIT "/MT /Zi /O2 /Ob1 /D NDEBUG")
6+
endif()

exposed/CMakeLists.txt

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,8 @@
1+
include_directories(
2+
${CMAKE_SOURCE_DIR}/include)
3+
4+
add_executable(CDemo
5+
CDemo.c)
6+
7+
target_link_libraries(CDemo
8+
slvs)

0 commit comments

Comments
 (0)