Skip to content

Commit

Permalink
Build lib_ui with cmake.
Browse files Browse the repository at this point in the history
  • Loading branch information
john-preston committed Nov 8, 2019
1 parent b7fed03 commit 02a71d7
Show file tree
Hide file tree
Showing 7 changed files with 34 additions and 10 deletions.
2 changes: 2 additions & 0 deletions CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,8 @@ cmake_minimum_required(VERSION 3.12)
cmake_policy(SET CMP0076 NEW)
cmake_policy(SET CMP0091 NEW)

set_property(GLOBAL PROPERTY USE_FOLDERS ON)

project(Telegram
LANGUAGES C CXX
VERSION 1.9.0
Expand Down
21 changes: 18 additions & 3 deletions Telegram/CMakeLists.txt
Original file line number Diff line number Diff line change
@@ -1,18 +1,33 @@
add_subdirectory(lib_rpl)
add_subdirectory(lib_crl)
add_subdirectory(lib_base)
add_subdirectory(lib_ui)
add_subdirectory(codegen)

# include(lib_ui/cmake/generate_styles.cmake)

# get_filename_component(src_loc "./SourceFiles" REALPATH)

# add_executable(Telegram WIN32 MACOSX_BUNDLE
# ${src_loc}/main.cpp
# )
# add_executable(Telegram WIN32 MACOSX_BUNDLE)
# init_target(Telegram)

# force_include(Telegram stdafx.h)

# set(telegram_sources
# PRIVATE
# main.cpp
# )

# nice_target_sources(Telegram ${src_loc} "${telegram_sources}")

# target_compile_definitions(Telegram
# PRIVATE
# TDESKTOP_API_ID=17349
# TDESKTOP_API_HASH=344583e45741c457fe1862106095a5eb
# )

# target_link_libraries(Telegram
# PRIVATE
# lib_base
# lib_ui
# )
2 changes: 1 addition & 1 deletion Telegram/lib_ui
2 changes: 2 additions & 0 deletions cmake/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -29,6 +29,8 @@ if (WIN32)
INTERFACE
/permissive-
# /Qspectre
/W1
/WX
/MP # Enable multi process build.
/EHsc # Catch C++ exceptions only, extern C functions never throw a C++ exception.
/w14834 # [[nodiscard]]
Expand Down
1 change: 1 addition & 0 deletions cmake/constants.cmake
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
get_filename_component(libs_loc "../Libraries" REALPATH)
get_filename_component(third_party_loc "Telegram/ThirdParty" REALPATH)
get_filename_component(submodules_loc "Telegram" REALPATH)

if(CMAKE_BUILD_TYPE STREQUAL "Debug")
set(build_debug 1)
Expand Down
14 changes: 9 additions & 5 deletions cmake/functions.cmake
Original file line number Diff line number Diff line change
Expand Up @@ -12,9 +12,13 @@ else()
endif()
endfunction()

function(init_target target_name)
function(init_target target_name) # init_target(my_target folder_name)
set(folder_name "${ARGV1}")
set_property(TARGET ${target_name} PROPERTY
MSVC_RUNTIME_LIBRARY "MultiThreaded$<$<CONFIG:Debug>:Debug>")
if (NOT "${folder_name}" STREQUAL "")
set_target_properties(${target_name} PROPERTIES FOLDER ${folder_name})
endif()
endfunction()

function(nice_target_sources target_name src_loc list)
Expand All @@ -30,16 +34,16 @@ function(nice_target_sources target_name src_loc list)
set(writing_now ${file})
else()
set(full_name ${src_loc}/${file})
if (${file} MATCHES "/win/" OR ${file} MATCHES "_win\.")
if (${file} MATCHES "/win/" OR ${file} MATCHES "_win\\.")
list(APPEND not_mac_sources ${full_name})
list(APPEND not_linux_sources ${full_name})
elseif (${file} MATCHES "/mac/" OR ${file} MATCHES "_mac\.")
elseif (${file} MATCHES "/mac/" OR ${file} MATCHES "_mac\\.")
list(APPEND not_win_sources ${full_name})
list(APPEND not_linux_sources ${full_name})
elseif (${file} MATCHES "/linux/" OR ${file} MATCHES "_linux\.")
elseif (${file} MATCHES "/linux/" OR ${file} MATCHES "_linux\\.")
list(APPEND not_win_sources ${full_name})
list(APPEND not_mac_sources ${full_name})
elseif (${file} MATCHES "/posix/" OR ${file} MATCHES "_posix\.")
elseif (${file} MATCHES "/posix/" OR ${file} MATCHES "_posix\\.")
list(APPEND not_win_sources ${full_name})
endif()
if ("${writing_now}" STREQUAL "PRIVATE")
Expand Down

0 comments on commit 02a71d7

Please sign in to comment.