Clean up/simplify build
This commit is contained in:
parent
a1e18b83cb
commit
006539b945
@ -8,7 +8,7 @@ if(CMAKE_SOURCE_DIR STREQUAL CMAKE_BINARY_DIR)
|
|||||||
" mkdir build && cd build && cmake ..")
|
" mkdir build && cd build && cmake ..")
|
||||||
endif()
|
endif()
|
||||||
|
|
||||||
set(CMAKE_MODULE_PATH ${CMAKE_MODULE_PATH}
|
list(APPEND CMAKE_MODULE_PATH
|
||||||
"${CMAKE_SOURCE_DIR}/cmake/")
|
"${CMAKE_SOURCE_DIR}/cmake/")
|
||||||
|
|
||||||
cmake_policy(SET CMP0048 OLD)
|
cmake_policy(SET CMP0048 OLD)
|
||||||
@ -56,7 +56,7 @@ set(ENABLE_SANITIZERS OFF CACHE BOOL
|
|||||||
"Whether to enable Clang's AddressSanitizer and UndefinedBehaviorSanitizer")
|
"Whether to enable Clang's AddressSanitizer and UndefinedBehaviorSanitizer")
|
||||||
set(ENABLE_OPENMP OFF CACHE BOOL
|
set(ENABLE_OPENMP OFF CACHE BOOL
|
||||||
"Whether geometric operations will be parallelized using OpenMP")
|
"Whether geometric operations will be parallelized using OpenMP")
|
||||||
set(ENABLE_LTO OFF CACHE BOOL
|
set(ENABLE_LTO OFF CACHE BOOL
|
||||||
"Whether interprocedural (global) optimizations are enabled")
|
"Whether interprocedural (global) optimizations are enabled")
|
||||||
|
|
||||||
set(OPENGL 3 CACHE STRING "OpenGL version to use (one of: 1 3)")
|
set(OPENGL 3 CACHE STRING "OpenGL version to use (one of: 1 3)")
|
||||||
@ -114,7 +114,12 @@ endif()
|
|||||||
if(ENABLE_OPENMP)
|
if(ENABLE_OPENMP)
|
||||||
find_package( OpenMP REQUIRED )
|
find_package( OpenMP REQUIRED )
|
||||||
if(OPENMP_FOUND)
|
if(OPENMP_FOUND)
|
||||||
set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} ${OpenMP_CXX_FLAGS}")
|
add_library(slvs_openmp INTERFACE)
|
||||||
|
target_compile_options(slvs_openmp INTERFACE ${OpenMP_CXX_FLAGS})
|
||||||
|
target_link_libraries(slvs_openmp INTERFACE
|
||||||
|
${OpenMP_CXX_LIBRARIES})
|
||||||
|
target_include_directories(slvs_openmp INTERFACE SYSTEM
|
||||||
|
${OpenMP_CXX_INCLUDE_DIRS})
|
||||||
message(STATUS "found OpenMP, compiling with flags: " ${OpenMP_CXX_FLAGS} )
|
message(STATUS "found OpenMP, compiling with flags: " ${OpenMP_CXX_FLAGS} )
|
||||||
endif()
|
endif()
|
||||||
endif()
|
endif()
|
||||||
@ -281,7 +286,6 @@ if(ENABLE_GUI)
|
|||||||
elseif(APPLE)
|
elseif(APPLE)
|
||||||
find_package(OpenGL REQUIRED)
|
find_package(OpenGL REQUIRED)
|
||||||
find_library(APPKIT_LIBRARY AppKit REQUIRED)
|
find_library(APPKIT_LIBRARY AppKit REQUIRED)
|
||||||
set(util_LIBRARIES ${APPKIT_LIBRARY})
|
|
||||||
else()
|
else()
|
||||||
find_package(OpenGL REQUIRED)
|
find_package(OpenGL REQUIRED)
|
||||||
find_package(SpaceWare)
|
find_package(SpaceWare)
|
||||||
|
@ -19,32 +19,62 @@ endif()
|
|||||||
configure_file(${CMAKE_CURRENT_SOURCE_DIR}/config.h.in
|
configure_file(${CMAKE_CURRENT_SOURCE_DIR}/config.h.in
|
||||||
${CMAKE_CURRENT_BINARY_DIR}/config.h)
|
${CMAKE_CURRENT_BINARY_DIR}/config.h)
|
||||||
|
|
||||||
|
# solvespace dependencies
|
||||||
|
add_library(slvs_deps INTERFACE)
|
||||||
|
target_include_directories(slvs_deps INTERFACE SYSTEM
|
||||||
|
${OPENGL_INCLUDE_DIR}
|
||||||
|
${ZLIB_INCLUDE_DIR}
|
||||||
|
${PNG_PNG_INCLUDE_DIR}
|
||||||
|
${FREETYPE_INCLUDE_DIRS}
|
||||||
|
${CAIRO_INCLUDE_DIRS}
|
||||||
|
${MIMALLOC_INCLUDE_DIR})
|
||||||
|
target_link_libraries(slvs_deps INTERFACE
|
||||||
|
dxfrw
|
||||||
|
${ZLIB_LIBRARY}
|
||||||
|
${PNG_LIBRARY}
|
||||||
|
${FREETYPE_LIBRARY}
|
||||||
|
${CAIRO_LIBRARIES}
|
||||||
|
mimalloc-static)
|
||||||
|
|
||||||
|
if(Backtrace_FOUND)
|
||||||
|
target_include_directories(slvs_deps INTERFACE SYSTEM
|
||||||
|
${Backtrace_INCLUDE_DIRS})
|
||||||
|
target_link_libraries(slvs_deps INTERFACE
|
||||||
|
${Backtrace_LIBRARY})
|
||||||
|
endif()
|
||||||
|
|
||||||
|
if(SPACEWARE_FOUND)
|
||||||
|
target_include_directories(slvs_deps INTERFACE SYSTEM
|
||||||
|
${SPACEWARE_INCLUDE_DIR})
|
||||||
|
target_link_libraries(slvs_deps INTERFACE
|
||||||
|
${SPACEWARE_LIBRARIES})
|
||||||
|
endif()
|
||||||
|
|
||||||
|
if(ENABLE_OPENMP)
|
||||||
|
target_link_libraries(slvs_deps INTERFACE slvs_openmp)
|
||||||
|
endif()
|
||||||
|
|
||||||
|
target_compile_options(slvs_deps
|
||||||
|
INTERFACE ${COVERAGE_FLAGS})
|
||||||
|
|
||||||
# platform utilities
|
# platform utilities
|
||||||
|
|
||||||
if(APPLE)
|
if(APPLE)
|
||||||
set(util_LIBRARIES
|
target_link_libraries(slvs_deps INTERFACE
|
||||||
${APPKIT_LIBRARY})
|
${APPKIT_LIBRARY})
|
||||||
endif()
|
endif()
|
||||||
|
|
||||||
# libslvs
|
# libslvs
|
||||||
|
add_library(slvs SHARED
|
||||||
set(libslvs_SOURCES
|
solvespace.h
|
||||||
|
platform/platform.h
|
||||||
util.cpp
|
util.cpp
|
||||||
entity.cpp
|
entity.cpp
|
||||||
expr.cpp
|
expr.cpp
|
||||||
constraint.cpp
|
constraint.cpp
|
||||||
constrainteq.cpp
|
constrainteq.cpp
|
||||||
system.cpp
|
system.cpp
|
||||||
platform/platform.cpp)
|
platform/platform.cpp
|
||||||
|
|
||||||
set(libslvs_HEADERS
|
|
||||||
solvespace.h
|
|
||||||
platform/platform.h)
|
|
||||||
|
|
||||||
add_library(slvs SHARED
|
|
||||||
${libslvs_SOURCES}
|
|
||||||
${libslvs_HEADERS}
|
|
||||||
${util_SOURCES}
|
|
||||||
lib.cpp)
|
lib.cpp)
|
||||||
|
|
||||||
target_compile_definitions(slvs
|
target_compile_definitions(slvs
|
||||||
@ -53,12 +83,7 @@ target_compile_definitions(slvs
|
|||||||
target_include_directories(slvs
|
target_include_directories(slvs
|
||||||
PUBLIC ${CMAKE_SOURCE_DIR}/include)
|
PUBLIC ${CMAKE_SOURCE_DIR}/include)
|
||||||
|
|
||||||
target_link_libraries(slvs
|
target_link_libraries(slvs PRIVATE slvs_deps)
|
||||||
${util_LIBRARIES}
|
|
||||||
mimalloc-static)
|
|
||||||
|
|
||||||
add_dependencies(slvs
|
|
||||||
mimalloc-static)
|
|
||||||
|
|
||||||
set_target_properties(slvs PROPERTIES
|
set_target_properties(slvs PROPERTIES
|
||||||
PUBLIC_HEADER ${CMAKE_SOURCE_DIR}/include/slvs.h
|
PUBLIC_HEADER ${CMAKE_SOURCE_DIR}/include/slvs.h
|
||||||
@ -72,70 +97,6 @@ if(NOT WIN32)
|
|||||||
PUBLIC_HEADER DESTINATION ${CMAKE_INSTALL_INCLUDEDIR})
|
PUBLIC_HEADER DESTINATION ${CMAKE_INSTALL_INCLUDEDIR})
|
||||||
endif()
|
endif()
|
||||||
|
|
||||||
# solvespace dependencies
|
|
||||||
|
|
||||||
include_directories(
|
|
||||||
${OPENGL_INCLUDE_DIR}
|
|
||||||
${ZLIB_INCLUDE_DIR}
|
|
||||||
${PNG_PNG_INCLUDE_DIR}
|
|
||||||
${FREETYPE_INCLUDE_DIRS}
|
|
||||||
${CAIRO_INCLUDE_DIRS}
|
|
||||||
${MIMALLOC_INCLUDE_DIR}
|
|
||||||
${OpenMP_CXX_INCLUDE_DIRS})
|
|
||||||
|
|
||||||
if(Backtrace_FOUND)
|
|
||||||
include_directories(
|
|
||||||
${Backtrace_INCLUDE_DIRS})
|
|
||||||
endif()
|
|
||||||
|
|
||||||
if(SPACEWARE_FOUND)
|
|
||||||
include_directories(
|
|
||||||
${SPACEWARE_INCLUDE_DIR})
|
|
||||||
endif()
|
|
||||||
|
|
||||||
if(OPENGL STREQUAL 3)
|
|
||||||
set(gl_SOURCES
|
|
||||||
render/gl3shader.cpp
|
|
||||||
render/rendergl3.cpp)
|
|
||||||
elseif(OPENGL STREQUAL 1)
|
|
||||||
set(gl_SOURCES
|
|
||||||
render/rendergl1.cpp)
|
|
||||||
else()
|
|
||||||
message(FATAL_ERROR "Unsupported OpenGL version ${OPENGL}")
|
|
||||||
endif()
|
|
||||||
|
|
||||||
set(platform_SOURCES
|
|
||||||
${gl_SOURCES}
|
|
||||||
platform/entrygui.cpp)
|
|
||||||
|
|
||||||
if(WIN32)
|
|
||||||
list(APPEND platform_SOURCES
|
|
||||||
platform/guiwin.cpp)
|
|
||||||
|
|
||||||
set(platform_LIBRARIES
|
|
||||||
comctl32
|
|
||||||
${SPACEWARE_LIBRARIES})
|
|
||||||
elseif(APPLE)
|
|
||||||
add_compile_options(
|
|
||||||
-DGL_SILENCE_DEPRECATION
|
|
||||||
-fobjc-arc)
|
|
||||||
|
|
||||||
list(APPEND platform_SOURCES
|
|
||||||
platform/guimac.mm)
|
|
||||||
else()
|
|
||||||
list(APPEND platform_SOURCES
|
|
||||||
platform/guigtk.cpp)
|
|
||||||
|
|
||||||
set(platform_LIBRARIES
|
|
||||||
${SPACEWARE_LIBRARIES})
|
|
||||||
|
|
||||||
foreach(pkg_config_lib GTKMM JSONC FONTCONFIG)
|
|
||||||
include_directories(${${pkg_config_lib}_INCLUDE_DIRS})
|
|
||||||
link_directories(${${pkg_config_lib}_LIBRARY_DIRS})
|
|
||||||
list(APPEND platform_LIBRARIES ${${pkg_config_lib}_LIBRARIES})
|
|
||||||
endforeach()
|
|
||||||
endif()
|
|
||||||
|
|
||||||
set(every_platform_SOURCES
|
set(every_platform_SOURCES
|
||||||
platform/guiwin.cpp
|
platform/guiwin.cpp
|
||||||
platform/guigtk.cpp
|
platform/guigtk.cpp
|
||||||
@ -143,7 +104,10 @@ set(every_platform_SOURCES
|
|||||||
|
|
||||||
# solvespace library
|
# solvespace library
|
||||||
|
|
||||||
set(solvespace_core_HEADERS
|
set(solvespace_core_gl_SOURCES
|
||||||
|
solvespace.cpp)
|
||||||
|
|
||||||
|
add_library(solvespace-core STATIC
|
||||||
dsc.h
|
dsc.h
|
||||||
expr.h
|
expr.h
|
||||||
polygon.h
|
polygon.h
|
||||||
@ -153,9 +117,7 @@ set(solvespace_core_HEADERS
|
|||||||
platform/platform.h
|
platform/platform.h
|
||||||
render/render.h
|
render/render.h
|
||||||
render/gl3shader.h
|
render/gl3shader.h
|
||||||
srf/surface.h)
|
srf/surface.h
|
||||||
|
|
||||||
set(solvespace_core_SOURCES
|
|
||||||
bsp.cpp
|
bsp.cpp
|
||||||
clipboard.cpp
|
clipboard.cpp
|
||||||
confscreen.cpp
|
confscreen.cpp
|
||||||
@ -207,40 +169,14 @@ set(solvespace_core_SOURCES
|
|||||||
srf/surfinter.cpp
|
srf/surfinter.cpp
|
||||||
srf/triangulate.cpp)
|
srf/triangulate.cpp)
|
||||||
|
|
||||||
set(solvespace_core_gl_SOURCES
|
target_link_libraries(solvespace-core PUBLIC slvs_deps)
|
||||||
solvespace.cpp)
|
|
||||||
|
|
||||||
add_library(solvespace-core STATIC
|
|
||||||
${util_SOURCES}
|
|
||||||
${solvespace_core_HEADERS}
|
|
||||||
${solvespace_core_SOURCES})
|
|
||||||
|
|
||||||
add_dependencies(solvespace-core
|
|
||||||
mimalloc-static)
|
|
||||||
|
|
||||||
target_link_libraries(solvespace-core
|
|
||||||
${OpenMP_CXX_LIBRARIES}
|
|
||||||
dxfrw
|
|
||||||
${util_LIBRARIES}
|
|
||||||
${ZLIB_LIBRARY}
|
|
||||||
${PNG_LIBRARY}
|
|
||||||
${FREETYPE_LIBRARY}
|
|
||||||
mimalloc-static)
|
|
||||||
|
|
||||||
if(Backtrace_FOUND)
|
|
||||||
target_link_libraries(solvespace-core
|
|
||||||
${Backtrace_LIBRARY})
|
|
||||||
endif()
|
|
||||||
|
|
||||||
target_compile_options(solvespace-core
|
|
||||||
PRIVATE ${COVERAGE_FLAGS})
|
|
||||||
|
|
||||||
# solvespace translations
|
# solvespace translations
|
||||||
|
|
||||||
if(HAVE_GETTEXT)
|
if(HAVE_GETTEXT)
|
||||||
|
get_target_property(solvespace_core_SOURCES solvespace-core SOURCES)
|
||||||
set(inputs
|
set(inputs
|
||||||
${solvespace_core_SOURCES}
|
${solvespace_core_SOURCES}
|
||||||
${solvespace_core_HEADERS}
|
|
||||||
${every_platform_SOURCES}
|
${every_platform_SOURCES}
|
||||||
${solvespace_core_gl_SOURCES})
|
${solvespace_core_gl_SOURCES})
|
||||||
|
|
||||||
@ -323,52 +259,82 @@ endif()
|
|||||||
if(ENABLE_GUI)
|
if(ENABLE_GUI)
|
||||||
add_executable(solvespace WIN32 MACOSX_BUNDLE
|
add_executable(solvespace WIN32 MACOSX_BUNDLE
|
||||||
${solvespace_core_gl_SOURCES}
|
${solvespace_core_gl_SOURCES}
|
||||||
${platform_SOURCES}
|
platform/entrygui.cpp
|
||||||
$<TARGET_PROPERTY:resources,EXTRA_SOURCES>)
|
$<TARGET_PROPERTY:resources,EXTRA_SOURCES>)
|
||||||
|
|
||||||
add_dependencies(solvespace
|
add_dependencies(solvespace
|
||||||
resources)
|
resources)
|
||||||
|
|
||||||
target_link_libraries(solvespace
|
target_link_libraries(solvespace
|
||||||
|
PRIVATE
|
||||||
solvespace-core
|
solvespace-core
|
||||||
${OPENGL_LIBRARIES}
|
${OPENGL_LIBRARIES})
|
||||||
${platform_LIBRARIES}
|
|
||||||
${COVERAGE_LIBRARY})
|
|
||||||
|
|
||||||
if(MSVC)
|
# OpenGL version
|
||||||
set_target_properties(solvespace PROPERTIES
|
if(OPENGL STREQUAL 3)
|
||||||
LINK_FLAGS "/MANIFEST:NO /SAFESEH:NO /INCREMENTAL:NO /OPT:REF")
|
target_sources(solvespace PRIVATE
|
||||||
|
render/gl3shader.cpp
|
||||||
|
render/rendergl3.cpp)
|
||||||
|
elseif(OPENGL STREQUAL 1)
|
||||||
|
target_sources(solvespace PRIVATE
|
||||||
|
render/rendergl1.cpp)
|
||||||
|
else()
|
||||||
|
message(FATAL_ERROR "Unsupported OpenGL version ${OPENGL}")
|
||||||
|
endif()
|
||||||
|
|
||||||
|
# Platform-specific
|
||||||
|
if(WIN32)
|
||||||
|
target_sources(solvespace PRIVATE
|
||||||
|
platform/guiwin.cpp)
|
||||||
|
|
||||||
|
target_link_libraries(solvespace PRIVATE comctl32)
|
||||||
elseif(APPLE)
|
elseif(APPLE)
|
||||||
|
target_compile_options(solvespace PRIVATE -fobjc-arc)
|
||||||
|
target_compile_definitions(solvespace PRIVATE GL_SILENCE_DEPRECATION)
|
||||||
|
|
||||||
|
target_sources(solvespace PRIVATE
|
||||||
|
platform/guimac.mm)
|
||||||
set_target_properties(solvespace PROPERTIES
|
set_target_properties(solvespace PROPERTIES
|
||||||
OUTPUT_NAME SolveSpace
|
OUTPUT_NAME SolveSpace
|
||||||
XCODE_ATTRIBUTE_ENABLE_HARDENED_RUNTIME "YES"
|
XCODE_ATTRIBUTE_ENABLE_HARDENED_RUNTIME "YES"
|
||||||
XCODE_ATTRIBUTE_PRODUCT_BUNDLE_IDENTIFIER "com.solvespace"
|
XCODE_ATTRIBUTE_PRODUCT_BUNDLE_IDENTIFIER "com.solvespace"
|
||||||
RUNTIME_OUTPUT_DIRECTORY "${CMAKE_BINARY_DIR}/bin")
|
RUNTIME_OUTPUT_DIRECTORY "${CMAKE_BINARY_DIR}/bin")
|
||||||
|
else()
|
||||||
|
target_sources(solvespace PRIVATE
|
||||||
|
platform/guigtk.cpp)
|
||||||
|
|
||||||
|
target_include_directories(solvespace PRIVATE SYSTEM
|
||||||
|
${GTKMM_INCLUDE_DIRS}
|
||||||
|
${JSONC_INCLUDE_DIRS}
|
||||||
|
${FONTCONFIG_INCLUDE_DIRS})
|
||||||
|
target_link_libraries(solvespace PRIVATE
|
||||||
|
${GTKMM_LIBRARIES}
|
||||||
|
${JSONC_LIBRARIES}
|
||||||
|
${FONTCONFIG_LIBRARIES})
|
||||||
|
endif()
|
||||||
|
|
||||||
|
if(MSVC)
|
||||||
|
set_target_properties(solvespace PROPERTIES
|
||||||
|
LINK_FLAGS "/MANIFEST:NO /SAFESEH:NO /INCREMENTAL:NO /OPT:REF")
|
||||||
endif()
|
endif()
|
||||||
endif()
|
endif()
|
||||||
|
|
||||||
# solvespace headless library
|
# solvespace headless library
|
||||||
|
|
||||||
set(headless_SOURCES
|
add_library(solvespace-headless STATIC EXCLUDE_FROM_ALL
|
||||||
|
${solvespace_core_gl_SOURCES}
|
||||||
platform/guinone.cpp
|
platform/guinone.cpp
|
||||||
render/rendercairo.cpp)
|
render/rendercairo.cpp)
|
||||||
|
|
||||||
add_library(solvespace-headless STATIC EXCLUDE_FROM_ALL
|
|
||||||
${solvespace_core_gl_SOURCES}
|
|
||||||
${headless_SOURCES})
|
|
||||||
|
|
||||||
target_compile_definitions(solvespace-headless
|
target_compile_definitions(solvespace-headless
|
||||||
PRIVATE -DHEADLESS)
|
PRIVATE HEADLESS)
|
||||||
|
|
||||||
target_include_directories(solvespace-headless
|
target_include_directories(solvespace-headless
|
||||||
INTERFACE ${CMAKE_CURRENT_SOURCE_DIR})
|
INTERFACE ${CMAKE_CURRENT_SOURCE_DIR})
|
||||||
|
|
||||||
target_link_libraries(solvespace-headless
|
target_link_libraries(solvespace-headless
|
||||||
solvespace-core
|
PRIVATE
|
||||||
${CAIRO_LIBRARIES})
|
solvespace-core)
|
||||||
|
|
||||||
target_compile_options(solvespace-headless
|
|
||||||
PRIVATE ${COVERAGE_FLAGS})
|
|
||||||
|
|
||||||
# solvespace command-line executable
|
# solvespace command-line executable
|
||||||
|
|
||||||
@ -432,4 +398,4 @@ if(APPLE)
|
|||||||
COMMENT "Bundling executable solvespace-cli"
|
COMMENT "Bundling executable solvespace-cli"
|
||||||
VERBATIM)
|
VERBATIM)
|
||||||
endif()
|
endif()
|
||||||
endif()
|
endif()
|
||||||
|
Loading…
Reference in New Issue
Block a user