c++ - How does Cmake find files? -


I'm trying to compile freepv () using CMak.

FreePav requires some modules such as zlib. I download the developer version of this module and copy it to my hard disk.

is included in the semicolon that tells a centimeter where to find the zlib library.

  ####################################### $ ####### ******** ****************************************************************************************** ********* ** # # This free PVP script attempts to find the header path of the JPEG Library and header file # # ZLIB_INCLUDE_DIR. # # ZLIB_LIBRARIES, requires libraries # # ZLIB_FOUND, either true or false ############################### ################## ######################## if (Win32) Fnd_pth (Zlib_include_dir Zlib .h $ {CMAKE_INCLUDE_PATH} $ ENV {included} set (ZLIB_NAMES z zlib zlib1 zlib1d zdll) FIND_LIBRARY (ZLIB_LIBRARY NAMES $ {ZLIB_NAMES} PATHS $ {CMAKE_LIBRARY_PATH} $ ENV {lib}) ELSE (WIN32) FIND_PHH (ZLIB_INCLUDE_DIR zlib.h / usr / local / include / usr / include) SET (ZLIB_NAMES z zlib zdll) FIND_LIBRARY (ZLIB_LIBRARY NAMES $ {ZLIB_NAMES} PATHS / usr / lib / usr / local / lib) ENDIF (WIN32) IF (ZLIB_INCLUDE_DIR and ZLIB_LIBRARY) SET ( ZLIB_FOUND TRUE) SET (ZLIB_LIBRARIES $ {ZLIB_LIBRARY}) ENDIF (ZLIB_INCLUDE_DIR and ZLIB_LIBRARY) IF (not ZLIB_FOUND) IF (ZLIB_FIND_REQUIRED) message (FATAL_ERROR "could not be found") endif (ZLIB_FIND_REQUIRED) endif O ZLIB_FOUND)   

Question:

Where should I be copied those files that I downloaded to zlib?

Can I copy something to my hard disk and then called an Environment variable: ZLIB_INCLUDE_DIR?

How does CMake FIND_PATH work?

Did you not tell whether you are on Windows or Linux / UNIX etc., because the above script has two parts To do something differently.

Let's start with the non-windows:

  FIND_PATH (ZLIB_INCLUDE_DIR zlib.h / usr / local / include / usr / include)   

This only searches for a file named zlib.h in the given directory and sets the CMKE variable ZLIB_INCLUDE_DIR to the DIR where the file was found.

The same thing happens to libraries, but oddly another way to joke (looks like a bug, imagine that you have zlib in / usr / lib and / usr / local / lib Installed and it is included in two different versions and mixes libraries).

  set (ZLIB_NAMES z zlib zdll) FIND_LIBRARY (ZLIB_LIBRARY name $ {ZLIB_NAMES} path / usr / lib / usr / local / lib)   

So The easiest way is to call only FindZLIB , which works better ... (see).

As it strange for the Windows platform:

  FIND_PATH (ZLIB_INCLUDE_DIR zlib.h include $ {CMAKE_INCLUDE_PATH} $ ENV {})   

This looks for the zlib.h file in the set in the default directory CMAKE_INCLUDE_PATH (see) and if it does not get there, path in the environment variable In the set.

  set (ZLIB_NAMES z zlib zlib1 zlib1d zdll) FIND_LIBRARY (ZLIB_LIBRARY named $ path $ {ZLIB_NAMES} {CMAKE_LIBRARY_PATH} $ ENV {lib})   

Dll IST similar, just this time CMAKE_LIBRARY_PATH is the content of or the contents of the environment variable LIB.

But yes, if you already know the right path, then you can just:

  SET (ZLIB_INCLUDE_DIR / path / to / the / zlib / include / DIR) SET (ZLIB_LIBRARIES / path / to / the / libary) SET (ZLIB_FOUND true)   

and ignore the whole code ...

Comments

Popular posts from this blog

Verilog Error: output or inout port "Q" must be connected to a structural net expression -

jasper reports - How to center align barcode using jasperreports and barcode4j -

c# - ASP.NET MVC - Attaching an entity of type 'MODELNAME' failed because another entity of the same type already has the same primary key value -