Skip to content
  • Categories
  • Recent
  • Tags
  • Popular
  • Users
  • Groups
  • Search
  • Get Qt Extensions
  • Unsolved
Collapse
Brand Logo
  1. Home
  2. Qt Development
  3. General and Desktop
  4. How to write multiported library?
Forum Updated to NodeBB v4.3 + New Features

How to write multiported library?

Scheduled Pinned Locked Moved Unsolved General and Desktop
2 Posts 2 Posters 187 Views
  • Oldest to Newest
  • Newest to Oldest
  • Most Votes
Reply
  • Reply as topic
Log in to reply
This topic has been deleted. Only users with topic management privileges can see it.
  • A Offline
    A Offline
    AndrzejB
    wrote on last edited by
    #1

    Especially using cmake.
    For example most files is common, but several files are for Linux and other for Windows.
    Or other example: library for SingleInstance using ICP irrespective of Qt5, Qt6 or WxWidgets.
    Which is good practice for it?

    1 Reply Last reply
    0
    • C Offline
      C Offline
      ChrisW67
      wrote on last edited by
      #2

      If you mean conditionally including files then something like this:

      set(COMMON_SOURCES file1.cpp file2.cpp ... )
      if (WIN32)
          set(PLATFORM_SOURCES win32file1.cpp win32file2.cpp ...}
      elseif (UNIX)
          set(PLATFORM_SOURCES unixfile1.cpp unixfile2.cpp ...}
      else()
        # generate error?
      endif()
      
      add_library(my_library ${COMMON_SOURCES} ${PLATFORM_SOURCES} )
      

      or

      • use an explicitly set variable rather than the WIN32/UNIX pre-defined variables
      • detect the presence of the platform specific libraries in order to determine what to build

      Or other example: library for SingleInstance using ICP irrespective of Qt5, Qt6 or WxWidgets.

      No idea what "SingleInstance using ICP" means

      1 Reply Last reply
      1

      • Login

      • Login or register to search.
      • First post
        Last post
      0
      • Categories
      • Recent
      • Tags
      • Popular
      • Users
      • Groups
      • Search
      • Get Qt Extensions
      • Unsolved