Skip to content

Commit

Permalink
Cmake windows build
Browse files Browse the repository at this point in the history
  • Loading branch information
TAR-ALEX committed May 12, 2023
1 parent 8574bed commit 8a806be
Show file tree
Hide file tree
Showing 3 changed files with 58 additions and 46 deletions.
14 changes: 8 additions & 6 deletions .gitignore
100644 → 100755
Original file line number Diff line number Diff line change
@@ -1,6 +1,8 @@
/build/
/.vscode/
/example
/vendor/
/tables

/build/
/.vscode/
/example
/vendor/
/tables
/stickersolve-gui
/Release/stickersolve-gui.exe

86 changes: 49 additions & 37 deletions CMakeLists.txt
100644 → 100755
Original file line number Diff line number Diff line change
@@ -1,37 +1,49 @@
cmake_minimum_required(VERSION 3.16)
project(stickersolve-gui)

set(CMAKE_CXX_STANDARD 20)
set(CMAKE_CXX_STANDARD_REQUIRED ON)
# set(CMAKE_VERBOSE_MAKEFILE ON)

set(CMAKE_RUNTIME_OUTPUT_DIRECTORY ${CMAKE_SOURCE_DIR})

# set(CMAKE_CXX_FLAGS "-Wall -Wextra")
set(CMAKE_CXX_FLAGS_DEBUG "-g -no-pie -Wall -Wextra")
set(CMAKE_CXX_FLAGS_RELEASE "-O3")
# set(CMAKE_CXX_FLAGS_RELEASE "-Ofast -zopt -flto -fremap-arrays -mllvm -reduce-array-computations=3 -faggressive-loop-transform") # for amd compiler

if(WIN32)
# see https://blog.kitware.com/create-dlls-on-windows-without-declspec-using-new-cmake-export-all-feature/
set(CMAKE_WINDOWS_EXPORT_ALL_SYMBOLS ON)
endif(WIN32)

# the -I flag in gcc
include_directories(${PROJECT_SOURCE_DIR}/include/, ${PROJECT_SOURCE_DIR}/vendor/include/)
set(CMAKE_BUILD_WITH_INSTALL_RPATH on)
set(CMAKE_INSTALL_RPATH "./vendor/lib" "./lib")
link_directories(${PROJECT_SOURCE_DIR}/vendor/lib)

file(GLOB_RECURSE APP_SOURCES CONFIGURE_DEPENDS "${PROJECT_SOURCE_DIR}/src/*" "${PROJECT_SOURCE_DIR}/include/*")
file(GLOB_RECURSE VENDOR_SOURCES CONFIGURE_DEPENDS "${PROJECT_SOURCE_DIR}/vendor/src/*" "${PROJECT_SOURCE_DIR}/vendor/include/*")

# creates ./build/bin/runner
add_executable(${PROJECT_NAME} ${APP_SOURCES} ${VENDOR_SOURCES})
target_compile_options(${PROJECT_NAME} PRIVATE -fPIC)
target_link_libraries(${PROJECT_NAME} pthread Qt5PrintSupport Qt5Network Qt5Widgets Qt5Gui Qt5Core -l:libboost_system.a -l:libboost_iostreams.a -l:libboost_filesystem.a)

# shared library
# set(LIBRARY_NAME World)
# add_library(${LIBRARY_NAME} SHARED ${LIB_SOURCES})
# target_link_libraries(${PROJECT_NAME} ${LIBRARY_NAME})
cmake_minimum_required(VERSION 3.16)
project(stickersolve-gui)

set(CMAKE_CXX_STANDARD 20)
set(CMAKE_CXX_STANDARD_REQUIRED ON)
# set(CMAKE_VERBOSE_MAKEFILE ON)

set(CMAKE_RUNTIME_OUTPUT_DIRECTORY ${CMAKE_SOURCE_DIR})

set(CMAKE_CXX_FLAGS_DEBUG "-g -no-pie -Wall")
set(CMAKE_CXX_FLAGS_RELEASE "-O3")

set(Qt5_DIR ./vendor/usr/lib/x86_64-linux-gnu/cmake/Qt5)

find_package(Qt5 REQUIRED Core Widgets Gui PATHS ./vendor/lib/cmake)

include_directories(${PROJECT_SOURCE_DIR}/include/, ${PROJECT_SOURCE_DIR}/vendor/include/)
set(CMAKE_BUILD_WITH_INSTALL_RPATH on)
set(CMAKE_INSTALL_RPATH "./vendor/lib" "./lib")
link_directories(${PROJECT_SOURCE_DIR}/vendor/lib)

file(GLOB_RECURSE APP_SOURCES CONFIGURE_DEPENDS "${PROJECT_SOURCE_DIR}/src/*" "${PROJECT_SOURCE_DIR}/include/*")
file(GLOB_RECURSE VENDOR_SOURCES CONFIGURE_DEPENDS "${PROJECT_SOURCE_DIR}/vendor/src/*" "${PROJECT_SOURCE_DIR}/vendor/include/*")


if(WIN32)
add_executable(${PROJECT_NAME} WIN32 ${APP_SOURCES} ${VENDOR_SOURCES})
target_compile_options(${PROJECT_NAME} PRIVATE)
# set_property(TARGET ${PROJECT_NAME} PROPERTY MSVC_RUNTIME_LIBRARY "MultiThreaded")
target_link_libraries(${PROJECT_NAME}
Qt5::Core
Qt5::Gui
Qt5::Widgets
${ADDITIONAL_LIBRARIES}
)
else()
add_executable(${PROJECT_NAME} ${APP_SOURCES} ${VENDOR_SOURCES})
target_compile_options(${PROJECT_NAME} PRIVATE -fPIC)
target_link_libraries(${PROJECT_NAME}
pthread
Qt5::Core
Qt5::Gui
Qt5::Widgets
-l:libboost_system.a
-l:libboost_iostreams.a
-l:libboost_filesystem.a
${ADDITIONAL_LIBRARIES}
)
endif()
4 changes: 1 addition & 3 deletions vendor.txt
Original file line number Diff line number Diff line change
@@ -1,8 +1,6 @@
deb-recurse-limit 2,

deb qtbase5-dev "./usr/include/x86_64-linux-gnu/qt5/" "./vendor/include/",
deb qtbase5-dev "./usr/lib/x86_64-linux-gnu/" "./vendor/lib/",
deb qtbase5-dev "./lib/" "./vendor/lib/",
deb "qtbase5-dev" "./usr/" "./vendor/usr/",

deb-recurse-limit 2,
deb libgl-dev "./usr/include/GL/" "./vendor/include/GL/",
Expand Down

0 comments on commit 8a806be

Please sign in to comment.